backend (Go) 개발

환경설정

꼰대코더 2025. 3. 4. 23:52

Go (aka Golang) 소개

2009년 google 에 의해 web application과 network server 개발 목적으로 심플 사용편리성을 염두에 두고 개발

C++과 같이 컴파일을 통해 실행되므로 빠른 실행속도와 강력한 병렬실행을 지원한다. 

 

개발 OS 환경에 맞게 인스톨

 

Download and install - The Go Programming Language

Documentation Download and install Download and install Download and install Go quickly with the steps described here. For other content on installing, you might be interested in: Download Go installation Select the tab for your computer's operating system

go.dev

 

hello world 프로젝트

$ mkdir hello
$ cd hello

 

모듈 관리 화일(go.mod)을 생성
⇒ 새로 생성할 프로젝트의 모듈의 이름(example/hello)을 등록하고 버젼정보를 go.mod 화일을 생성해 저장한다.
⇒ 나중에 필요한 외부 모듈을 go get 으로 불러들일때도 go.mod 에 외부 의존 모듈로서 등록된다.

⇒  이는 컴파일을 하기위해 필요한 모듈들의 정보를 미리 알려주어야 하는 필요성에서 이다.

$ go mod init example/hello

 

hello.go

package main 

import "fmt" 

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

 

build 는 현재폴더(hello)에 바이너리를 출력을하고 install 은 바이너리를 /home/user/go/bin 에 출력을 한다.
/home/user/go/bin 의 확인은 $go list -f '{{.Target}}' 으로 확인 가능.

$ go build
$ go install

'backend (Go) 개발' 카테고리의 다른 글

http fileupload  (0) 2025.03.08
http parseQuery  (0) 2025.03.08
http JSON  (0) 2025.03.08
Build HTTP Server  (0) 2025.03.05