This is a creation in Article, where the information may have evolved or changed.
This blog is my own from the beginning to build, in the setting of syntax highlighting encountered a lot of problems, the main reason, is the online search a lot of things, mostly the same content, but according to this content can not build a go language development environment, in order to reduce unnecessary trouble for everyone, Now I'm going to talk to you about the process I'm building.
I use the environment is CentOS6.5 version, using the virtual machine version, because it may often build a new environment, I have a virtual machine VM10 pure version of the system, the download address is as follows: Pure version of the virtual machine system please select the Centos_64.rar file
I use the Go compiler is 1.5 version, is also the latest version, download address is: Download the address Please select the Go Language development folder, and will download all of the content, my 64-bit operating system, if you are 32-bit operating system, you need to download 32-bit, the construction method is identical to 64 bits
Then we start building the environment.
1. Install the Go Language compilation environment
1.1 Execute TAR-ZXVF go1.5.linux-amd64.tar.gz command extract File
1.2 Cut the extracted folder into the/usr/local directory, it can also be replaced by other folders, but the proposal is placed under/usr/local
1.3 New Go language download Catalog
Execute command mkdir/go_src, this directory as the default path of the Go language download component, of course, if you do not want to use this path, you can completely customize, in the following steps remember to change to your own path.
1.3 Setting environment variables
Execute the vi/etc/profile command to modify the system configuration information and add the following:
Where export path= $PATH:/usr/local/go/bin is to add the path of the go language compiler to the system path, the following sentence is to add our new directory to the environment variable, this path will become the default path of the Go language download component
1.4 Make configuration effective, execute Source/etc/profile command
1.5 Okay, now that the go language development environment is basically built, let's try the following commands
Go
Go version
1.6 We're writing a test program.
Execute VI test.go Enter the following code
[Plain]View Plain Copy
- Package Main
- Import "FMT"
- Func Main () {
- Fmt. Printf ("Hello world...\n");
- }
Execute the Go build test.go command to start compiling and generate the test executable file to execute the file
2. Well, when it comes to this step, the go language development environment is set up, but when we write the code, we find that the grammar of Go is not bright, and it's always a bad habit.
Just like this, OK, next we set a syntax highlighting, just now we downloaded a total of three files, two out of two files is what we use to set syntax highlighting
2.1 Unzip Gocode, perform unzip Gocode-master.zip
2.2 Enter the Gocode-master/vim directory and execute the update.sh
2.3 Next we go to the directory under the. Vim folder to view the contents of the file (directly to CD, CD. Vim, the folder is an Incognito folder, LS does not display, but ls-a can)
2.4 Create a new syntax folder and put in the Go.vim file we came to in Beijing
2.5 Go back to the user's root directory (just tap the CD command), open the. vimrc file, and type the following sentence configuration
[Plain]View Plain Copy
- FileType plugin on
- Syntax on
- Au bufread,bufnewfile *.go set Filetype=go
2.6 OK, restart the terminal, open the Test.go file again, the miracle happened
Well, if there is any doubt, you can directly to my comment, I see will immediately reply to you, the Go.vim is an open source file, I downloaded on GitHub, interested friends can also search their own other configuration files and share to me, thank you.