본문 바로가기
Go 언어

go 설치부터 hello world 까지(ubuntu)

by SpeeDr00t 2017. 9. 26.
반응형

go 설치부터 hello world 까지.

 

1. go 홈페이지  https://golang.org/dl/

2. 설치

chmod 755 go.sh

.  go.sh

#
# chmod 755 go.sh
# . go.sh
#
cd ~
wget https://go.dev/dl/go1.19.5.linux-amd64.tar.gz
tar xvfz go1.19.5.linux-amd64.tar.gz
mkdir -p ~/workplace/go
echo 'export GOROOT=$HOME/go' >> ~/.bashrc
echo 'export GOPATH=$HOME/workplace/go' >> ~/.bashrc
. ~/.bashrc
echo 'export PATH=$GOPATH/bin:$GOROOT/bin:$PATH' >> .bashrc
. ~/.bashrc
go version
cd ~/workplace/go
pwd
wget https://gist.githubusercontent.com/ox1111/6ab8057f907a48aaea21a85c78496c38/raw/18f83a9bd3737b372a59d50ff43b9e5ba50a661a/hello.go
echo 'hello.go'
echo '-----------------------------'
cat hello.go
echo '-----------------------------'
echo ''
echo 'cmd > go run hello.go'
go run hello.go
view raw go.sh hosted with ❤ by GitHub

3. helloworld.go 소스

package main
import "fmt"
func main() {
fmt.Printf("Hello, world.\n")
}
view raw hello.go hosted with ❤ by GitHub

4. 결과

go run hello.go

 

https://www.youtube.com/watch?v=DsiTeAcBp6E 

 

 

 

반응형

'Go 언어' 카테고리의 다른 글

[go언어]http request  (0) 2016.07.11
go 설치부터 hello world 까지(windwos)  (0) 2016.07.11