3 ms·
Even easier: just put your files in a directory and run 'go build' in that directory. If you have libraries, put them down lib/lib_name/lib_name.go, and your bu
by falcolas 12y ago
Even easier: just put your files in a directory and run 'go build' in that directory. If you have libraries, put them down lib/lib_name/lib_name.go, and your build from the root directory will work fine. The compiled lib files will not be in your current directory, but that's usually OK.
For a working example, have a look at the logstash-forwarder code structure, it's how they do it, and you can build that from any directory you want.
And if you really want to set up go path in your current directory, use a make file and set up a target with 'env GOPATH=$(pwd) go install'
- rakoo 12y ago2 problems: - libraries are duplicated left and right. If I want to use the same library in multiple projects, it will be in each project's lib (note that this is how you'd vendor, but it's something else) - resetting env for each command you run sounds heavier, and the day will come when you will forget to do it and you'll run into problems.
- falcolas 12y agoDuplication depends on how you pull them in. For 3rd party libs, you'll pull them in via 'go get', and they will reside in the normal GOROOT, which is appropriate. It's just the libs you write for the particular project which would go down the local lib directory. Resetting the env isn't my preferred choice, but if you put it in a make file, it becomes hard to forget. Especially if you are in the habit of reusing make files between projects with a few customizations, which is my preferred setup.