Подготовка окружения для программирование в Linux на GO



https://gitlab.com/rvasily/msu-go-11/tree/master


Инсталляция:

# cd /tmp/
# wget --no-check-certificate https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
# tar -C /usr/local -xzf go1.8.linux-amd64.tar.gz

# echo 'export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/GO
export PATH=$PATH:$GOPATH/bin' >> /etc/profile

# source /etc/profile

# go version
go version go1.8 linux/amd64


Пример компиляции из примера к видео

# cd /tmp/
# git clone https://gitlab.com/rvasily/msu-go-11
# cd /tmp/msu-go-11/1/

# go run ./0_hello/main.go
Hello, World!

# go build ./0_hello/main.go

// Получился main

# ./main
Hello, World!


Мой вариант инсталляции GO (в контейнере docker с Ubuntu)

$ project_name=go-dev
$ echo $project_name
go-dev


$ project_folder=~/projects/dev/go/
$ echo $project_folder
$ mkdir -p ${project_folder}/${project_name}


1
2
3
4
5
6
$ docker run -it \
-p 80:8080 -p 1337:1337 -p 3000:3000 -p 4000:4000 -p 5000:5000 -p 6000:6000 -p 7000:7000 -p 8000:8000 -p 9000:9000 \
--name ${project_name} \
-v ${project_folder}/${project_name}:/project \
node \
/bin/bash


# apt-get update
# apt-get install -y vim git


# cd /tmp/
# wget --no-check-certificate https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz


# tar -xvzpf go1.9.2.linux-amd64.tar.gz
# mkdir -p /opt/go/1.9.2
# mv go/* /opt/go/1.9.2/
# ln -s /opt/go/1.9.2 /opt/go/current


# username=developer

# adduser --disabled-password --gecos "" ${username}

# chown -R ${username} /project/

# su - ${username}


$  vi ~/.bashrc


In the bottom I am add

1
2
3
4
###############################
# USER DEFINED
. ~/.bash_profile
###############################


$ echo "export PS1='$ '" >> ~/.bash_profile


$ vi ~/.bash_profile


after

# User specific environment and startup programs


#### GO 1.9.2 #######################

	export GO_HOME=/opt/go/current
    export GOPATH=$HOME/go
	export PATH=${GO_HOME}/bin:$PATH

#######################################


 $ source ~/.bash_profile


$ mkdir -p $GOPATH/src


$ go version
go version go1.9.2 linux/amd64


Доп плагины для разработки на GO в Visual Studio Code

Rich Go Language support for Visual Studio