Created
July 22, 2013 07:52
-
-
Save timrandg/6052056 to your computer and use it in GitHub Desktop.
Go packaging system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1. export GOPATH='~/Desktop/go/project' #set the GOPATH to the pwd | |
| 2. mkdir -p $GOPATH/{bin,pkg,src} #create the required subdirectory sturcture: {bin,pkg,src} | |
| 3. tree $GOPATH | |
| /Users/Tim/Desktop/go/project | |
| ├── bin | |
| ├── pkg | |
| └── src | |
| 4. mkdir $GOPATH/src/my_new_package #create a package folder with the same name as the package itself | |
| 5. touch $GOPATH/src/my_new_package/my_new_package.go | |
| 6. subl $GOPATH/src/my_new_package/my_new_package.go | |
| #add content | |
| 7. cd $GOPATH/src/my_new_package | |
| 8. tree . | |
| /Users/Tim/Desktop/go/project | |
| ├── bin | |
| ├── pkg | |
| └── src | |
| └── file | |
| └── file.go | |
| 9. go install #go install creates new linkable files and stores them in the pkg folder by archetecture | |
| 10. tree . | |
| /Users/Tim/Desktop/go/project | |
| ├── bin | |
| ├── pkg | |
| │ └── darwin_amd64 | |
| │ └── file.a | |
| └── src | |
| └── file | |
| └── file.go | |
| 11. now no matter where the main go file lives on the system you can | |
| import "file" | |
| because the $GOPATH allows file to be found. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment