Method of setting up golang environment and vim highlighting Go keyword Settings under Centos

  • 2020-06-03 06:43:21
  • OfStack

1. Centos builds go environment

1: download https: / / golang org/dl/download go1.4.1.Linux-amd64.tar.gz ArchiveLinux64-bit

2: Switch sudo permission to unzip to /usr/local/ directory tar xzvf go1.4.1.linux-amd64.tar.gz -C /usr/local/

3: Return normal user permissions

4: Set up PATH

 vi ~/.bash_profile

    export GOROOT=/usr/local/go
    export GOBIN=$GOROOT/bin
    export GOPATH=$HOME/golang_git  This is set to Git go Library when the download path 

    export PATH

5: ~/.bash_profile complete

6: test

vi hello.go

package main
import "fmt"

func main(){
    fmt.Printf("what is a fucking day\n")

go build ES33en. go

perform ./hello

7: The go keyword in vim is not highlighted. google handles it

Go language comes with vim syntax highlighting files.

1: Turn on vim syntax highlighting

vim ~/.vimrc
syntax on
set fencs=utf-8,gbk

2: /usr/local/go/misc/vim/ Copy the file to ~/.vim/directory (new if there is no directory)

  mkdir ~/.vim
  cp -R /usr/local/go/misc/vim/* ~/.vim/

3: new ~/.vim/ftdetect/go.vim , add the following: au BufRead,BufNewFile *.go set filetype=go

   echo "au BufRead,BufNewFile *.go set filetype=go" > ~/.vim/ftdetect/go.vim

In just 3 steps, turn on the vim go keyword to highlight the rhythm


Above is the whole content of this article, I hope the content of this article to your study or work to bring 1 definite help, if you have any questions you can leave a message to communicate.

Related articles: