去安装:将非源文件添加到内置包中

My $GOPATH looks like this:

src/
  mypkg/
    source.go
    config.txt
bin/
  mypkg
pkg/
  somestuff/

When I build my package with go install (that builds and places the executable in bin), I'd like config.txt to be copied in that folder together with the executable. Is there a way to do so?

Sorry if I didn't find a way that may look obvious to you, but I'm new to programming, especially to Go.

You can "pack" the static files (text, images etc.) by including it into a .go file (usually automatically generated) and then compiling it into the stand-alone binary. You can do it by using https://github.com/golang/tools/blob/master/godoc/static/makestatic.go or with https://github.com/jteeuwen/go-bindata. See http://blog.ralch.com/tutorial/golang-embedded-resources/ for more information and examples.