본문 바로가기

🔒 golang

golang 설치 후 기본코드 작성 및 실행하기

1. vs code를 다운받고 설치

2. https://go.dev/dl/

 

All releases - The Go Programming Language

All releases After downloading a binary release suitable for your system, please follow the installation instructions. If you are building from source, follow the source installation instructions. See the release history for more information about Go relea

go.dev

해당 사이트로 이동하여 os 맞는 버전을 다운로드 후 설치

3. cmd > go version 입력하여 정상적으로 출력 여부 확인

4. 어떤 경로에서도 go 언어를 실행하기 위한 환경변수 세팅하기

> 시스템 변수에서 C: 드라이브에 설치된 GO 경로를 등록 > C:\Program Files\Go\bin

5. 작업 폴더는 임의의 폴더에 생성한다.

> 그리고 생성한 폴더를 vs code에서 오픈한다.

6. vs code에서 go 확장 라이브러리 설치

> 임의의 파일명 생성 > test.go

package main

import "fmt"

func main() {
	fmt.Println("Hello world!")
}

7. 실행

go run .\lesson.go

결과

Hello world!

8. exe 파일로 생성하기

go build .\lesson.go

- 실행하기

.\lesson.exe
Hello world!

'🔒 golang' 카테고리의 다른 글

golang 조건문 if  (0) 2023.03.28
golang 명시적, 묵시적 선언  (0) 2023.03.28
golang 변수와 데이터 형  (0) 2023.03.28