What is meant by immutable?

Immutable means that once the constructor for an object has completed execution that instance can’t be altered. This is useful as it means you can pass references to the object around, without worrying that someone else is going to change its contents. Especially when dealing with concurrency, there are no locking issues with objects that … Read more

Can I ‘git commit’ a file and ignore its content changes?

Sure, I do exactly this from time to time using git update-index –assume-unchanged [<file> …] To undo and start tracking again (if you forgot what files were untracked, see this question): git update-index –no-assume-unchanged [<file> …] Relevant documentation: –[no-]assume-unchanged When this flag is specified, the object names recorded for the paths are not updated. Instead, … Read more

What is the best way to test for an empty string in Go?

Both styles are used within the Go’s standard libraries. if len(s) > 0 { … } can be found in the strconv package: http://golang.org/src/pkg/strconv/atoi.go if s != “” { … } can be found in the encoding/json package: http://golang.org/src/pkg/encoding/json/encode.go Both are idiomatic and are clear enough. It is more a matter of personal taste and … Read more

Eclipse Optimize Imports to Include Static Imports

I’m using Eclipse Europa, which also has the Favorite preference section: Window > Preferences > Java > Editor > Content Assist > Favorites In mine, I have the following entries (when adding, use “New Type” and omit the .*): org.hamcrest.Matchers.* org.hamcrest.CoreMatchers.* org.junit.* org.junit.Assert.* org.junit.Assume.* org.junit.matchers.JUnitMatchers.* All but the third of those are static imports. By … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)