Writing, building, installing, and testing Go code
Why Stack Overflow recommends it
Stack Overflow users link it when answering GOPATH, workspace layout and package import problems, since seeing the setup done is easier than reading about it.
Recommended by 2 people across 2 different months, 2013 to 2015.
What it is
A short 2012 screencast from the official Go channel, presented by Andrew Gerrand, that shows how to set up a GOPATH workspace, write commands and packages, build and install with the go tool, and write unit tests with the testing package. It is aimed at newcomers to the language.
What people said
Recommends 0x434D53 · 2013-12 · Stack Overflow · on “cannot download, $GOPATH not set”
Watch a Video In general, I always recommend this official video from Go to get a quick overview on the matter: [this video] It's easier to be shown than to be told. @jwfearn [LINK] paraphrased the important part of the video: export GOPATH="${HOME}/gocode"; export PATH="${PATH}:${GOPATH}/bin"; mkdir -p "${GOPATH}"
Recommends Joshua Pinter · 2014-04 · Stack Overflow · on “How to import local packages without gopath”
I recommend taking a look at this intro video for a better understanding of **packages** and the **GOPATH**. [this video]
Cites Salah Eddine Taouririt · 2013-09 · Stack Overflow · on “Go code organisation best practice”
After reading How to Write Go Code [LINK] , and watching this screencast [this video] , I just want to ask: Is having multiple directories in the GOPATH variable environment considered a good practice ?
Cites kik · 2014-05 · Stack Overflow · on “Is it recommended to keep a program sources (as opposed to lib sources) in a single file?”
I am making my first steps into Go and obviously am reasoning from what I'm used to in other languages rather than understanding go specificity and styles yet. I've decided to rewrite a ruby background job I have that takes ages to execute. It iterates over a huge table in my database and process data individually for each row, so it's a good candidate for parallelization. Coming from a ruby on rails task and using ORM, this was meant to be, as I thought of it, a quite simple two files program: one that would contain a struct type and its methods to represent and work with a row and the main file to operate the database query and loop on rows (maybe a third file to abstract database access l
Cites VonC · 2014-08 · Stack Overflow · on “importing a git-submodule into a golang gae app”
" Organizing Go code [LINK] " mentions: An import path is the string with which users import a package. It specifies the directory (relative to $GOROOT/src/pkg or $GOPATH/src ) in which the package's source code resides. So make sure to use an import statement referring to a path which exists in your $GOPATH/src . ( GOPATH being your "workspace", in which you have namespaces, as shown in this video [this video] ). Also make sure you build first openid/src/openid sources. And install it ( go install ). As detailed in this answer [LINK] : Import paths can be be globally unique. In conjunction with GOPATH , import path can be translated unambiguously to a directory path. Any directory path under GOP
Cites Thibaud Clement · 2015-07 · Stack Overflow · on “Go: "stat hello.go: no such file or directory"”
Following the explanation of Andrew Gerrand in Writing, building, installing, and testing Go code [this video] , I configured my Go workspace as follows: 1. Create workspace First, since I want my Go code to be in my_user_name/code/go , I started by creating the corresponding folder: $ cd code $ mkdir go 2. Setup GOPATH Then I configured the GOPATH: $ cd $ export GOPATH=$HOME/code/go $ cd code/go 3. Add files to workspace Last, I manually (through the Finder) moved my hello.go file into the workspace and ran: $ go run hello.go Worked like a charm.