book_lover
2024. 6. 25. 07:32
Winodws
- https://golang.org에서 다운로드 후 설치
- https://git-scm.com에서 다운로드 후 설치
- Visual Studio Code 다운로드 후 설치
- Go 확장판 설치
- Go 확장판 설치
PS D:\Tucker_go> cd .\hello\
PS D:\Tucker_go\hello> ls
PS D:\Tucker_go\hello> go run hello.go
Hello, World!
PS D:\Tucker_go\hello> go mod init goprojects/hello
go: creating new go.mod: module goprojects/hello
go: to add module requirements and sums:
go mod tidy
PS D:\Tucker_go\hello> ls
디렉터리: D:\이용환\개발\Tucker_go\hello
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2024-06-25 오전 6:07 35 go.mod
-a---- 2024-06-25 오전 6:04 81 hello.go
PS D:\Tucker_go\hello> go build
PS D:\Tucker_go\hello> ls
디렉터리: D:\Tucker_go\hello
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2024-06-25 오전 6:07 35 go.mod
-a---- 2024-06-25 오전 6:08 1989120 hello.exe
-a---- 2024-06-25 오전 6:04 81 hello.go
PS D:\Tucker_go\hello> .\hello.exe
Hello, World!
Linux
- https://golang.org에서 다운로드 후 설치
- https://git-scm.com에서 다운로드 후 설치
- Visual Studio Code 다운로드 후 설치
~/.profile에 go 경로 설정
[root@reca1 ~]# vi .profile
# .profile에 경로 설정
export PATH=$PATH:/usr/bin/go
[root@reca1 ~]# which go
/usr/bin/go
[root@reca1 ~]# source ~/.profile
[root@reca1 ~]# git version
git version 2.43.0
첫 번째 코드
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
go mod init [name명 지정]
# ex
# go mod init goproject/hello
go build
#Winodws
./hello.exe
#Linux
./hello