From fe99e70983b80346aa76420da0461847b879f105 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Tue, 22 May 2018 10:51:54 +1000 Subject: [PATCH] hkghghjg --- notes/go.notes | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 notes/go.notes diff --git a/notes/go.notes b/notes/go.notes new file mode 100644 index 000000000..1e0c0b8d0 --- /dev/null +++ b/notes/go.notes @@ -0,0 +1,78 @@ +TODO: + +committing +blowing away files: + if it's untracked, delete it + if it's tracked, check it out + + + +----------------------------------------------------------- + GO +----------------------------------------------------------- + +Running and Building: + +$ go run hello-world.go +hello world + +$ go build hello-world.go +$ ls +hello-world hello-world.go + +$ ./hello-world +hello world + +----------------------------------------------------------- + DIRECTORY STRUCTURE +----------------------------------------------------------- + +https://golang.org/doc/code.html + +if you don't have your GOPATH exported, do so with +export GOPATH=$(go env GOPATH) + +you have a GOPATH which points to e.g. ~/go/ +this is where everything in go is stored. + +it has three directories, + - src + - pkg + - bin + +installed programs have their executables stored in bin +all your project and the src code of other people's projects are in src, with paths identifying them e.g. +src/github.com/jesseduffield/gitgot + +If you want to make an executable, give every file in your project directory `package main`, otherwise if you want to make a package, name everything `package mypackage`. This name should be the name of the project directory for your project. + +to install a program, inside the project folder +go install + +This adds the program to /bin + +to build a package, inside the project folder +go build + +this adds the package to /pkg so that it can be linked easily in the future. + +to build and run your program just do this: + +~/github.com/jesseduffield/gitgot: +▶ go install && gitgot + +----------------------------------------------------------- + BUILD SYSTEMS +----------------------------------------------------------- + +Currently for installs I'm using +/Users/jesseduffieldduffield/Library/Application Support/Sublime Text 3/Packages/User/custom_go_install.sublime-build + +note that the argument to go install should be the directory from the end of /src/ onwards. + +----------------------------------------------------------- + FMT +----------------------------------------------------------- + +casting anything to a string +fmt.Sprint(thing)