Environment variables:
Gopath is a path list, similar to the path settings:
Gopath =/home/user/go:/home/user/workspace_go :***
After creating a workspace, you can configure gopath (the configuration file is ~ /. Bash_profile ).
Export gopath =/users/user name/go:/users/user name/Documents documents/workspace/workspace_go
Set environment variables on Mac:
1. Open the Application> utility> terminal;
2. Locate your user's home directory in the terminal, and enter: Cd ~ ;
3. Create an empty file and enter touch. bash_profile;
4. edit the file and enter: open. bash_profile;
5. In this file, enter: Export path =$ {path }:< file directory>;
6. To add other environment variables such as java_home, enter: Export java_home =/library/Java
/Home;
7. Run source. bash_profile to restart the terminal and test.
About sublime:
1. install package Control
CTRL + 'Open the command line and execute the following code:
Import urllib2, OS; pF = 'package control. sublime-package '; IPP = sublime. installed_packages_path (); OS. makedirs (IPP) if not OS. path. exists (IPP) else none; urllib2.install _ opener (urllib2.build _ opener (urllib2.proxyhandler (); open (OS. path. join (iPP, PF), 'wb '). write (urllib2.urlopen ('HTTP: // sublime.wbond.net/'{pf.replace ('', '% 20 ')). read (); print 'Please restart sublime text to finish installation' 2. install the gosublime Plugin:
Command + Shift + P open package control, enter PCIP (package control: the abbreviation of install package), and then enter the installation package name
3. Compile the go file
Command + B
Go build ***. Go
4. Run
Run ***. Go
What I learned in Mac + sublime + golang environment Configuration