export is for linux. The equivalent for windows in this case is set GOPATH=%USERPROFILE%\gocode, although if your gocode dir is in the root of your C: drive you’d want to do set GOPATH=C:\gocode instead.
If you want to persist the setting, go to Control Panel, make sure it’s set to large or small icons (drop down setting top right), select System, then Advanced system settings and then under the tab Advanced click the button Environment Variables.... You probably want to add your GOPATH to your user variables, i.e., under User variables for <your username>.
Running go install within a project folder will compile the binary and make it available within %GOPATH%\bin and thus available on your path for execution. I usually just use go run file.go to avoid having to run two commands… Also, I sometimes forget to run go install before testing my binary and I wonder why my code changes arent working
Just curious, whats your GOROOT (where go itself is stored, this var should also be set)? ~ is a linux shortcut to /home/mitt. You seem to be storing your code at C:\gocode (I want t make sure there’s not confusion between GOROOT and GOPATH).
So for you, you should have a final path of C:\gocode\src\sitepoint.com\mitt
My recommended setup for Go on win7 would be to have your go installation at c:\go (GOROOT=c:\go) and you projects stored at c:\users\mitt\projects\go (GOPATH=c:\users\mitt\projects\go) which would make your path %PATH%;%GOROOT%\bin;%GOPATH%\bin;
You already seem to have go in your path var just fine or else ‘go’ would not be available as a command in cmd.exe. Once you set your GOPATH correctly, try the following:
go get github.com/gorilla/mux
This command should automatically fetch the gorillia/mux lib into src\github.com\gorilla\mux within your GOPATH, assuming you have git command available in cmd.exe
the -p switch on linux is create all directories in the path that don’t exist, which is default behavior on windows, so you don’t need it there. Also, you need backslashes instead of forward slashes in windows, so it becomes
Okay, so have you decided if you’re going to keep it at c:\gocode or move it to your home folder?
You can set it temporarily (for the duration your cmd.exe window is open) by using the command set GOPATH=c:\gocode or permanently by following the directions Scallio gave earlier (advanced system settings). I believe you’ll need this set if you want to run certain commands such as ‘go install’
set GOPATH seemed to work though I don’t see it in the path variables.
And an empty github,com/gorilla folder was created inside gocode/src
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Allan>cd \
C:\>set GOPATH=C:\gocode
C:\>go get github.com/gorilla/mux
go: missing Git command. See http://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in %PATH%
C:\>cd c:\gocode
c:\gocode>go get github.com/gorilla/mux
go: missing Git command. See http://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in %PATH%
c:\gocode>
So because you set the environment variable temporarily, you would then also have to reset path to include %GOPATH%\bin. It only evaluates those variables upon start up of the command prompt. For convenience you’ll want to set it permanently.
go: missing Git command. See http://golang.org/s/gogetcmd
package github.com/gorilla/mux: exec: "git": executable file not found in %PATH%
This didn’t work because you don’t have git installed. You don’t need it unless you plan on using some third party packages in your applications, and retrieving them using the go get utility.