Is there any way to access private fields of a struct from another package?

There is a way to read unexported members using reflect (in Go < 1.7) func read_foo(f *Foo) { v := reflect.ValueOf(*f) y := v.FieldByName(“y”) fmt.Println(y.Interface()) } However, trying to use y.Set, or otherwise set the field with reflect will result in the code panicking that you’re trying to set an unexported field outside the package. … Read more

How to register a local git package in Bower?

Option 1: Public Bower registration Bower is built mostly to share public (client-side) code in a “non-opinionated” manner. The primary use case, then, is to have a publicly accessible repository (on GitHub) that is registerd with a name and git repository url. I just did this myself: bower register linksoup git://github.com/automatonic/linksoup This is just telling … Read more

What do the *-dev packages in the Linux package repositories actually contain?

The *-dev packages most often contain the headers related to a library’s interface. Next most common are package-config files (*.pc) describing build options and staticly linked libraries. In general, if you want to know the contents of a package you have installed, dpkg -L pkgname will get you that. The apt-file program can tell you … Read more

Go build: “Cannot find package” (even though GOPATH is set)

It does not work because your foobar.go source file is not in a directory called foobar. go build and go install try to match directories, not source files. Set $GOPATH to a valid directory, e.g. export GOPATH=”$HOME/go” Move foobar.go to $GOPATH/src/foobar/foobar.go and building should work just fine. Additional recommended steps: Add $GOPATH/bin to your $PATH … Read more