hello.exe를 만들기 위한 기본적인 디렉터리 구조
ㅡ hello
ㅡㅡ go.mod (go mod init hello으로 생성됨, go mod tidy로 수정됨)
ㅡㅡ pkg1
ㅡㅡㅡ pkg1.go
package pkg1 // Imported Packages import ( "..." "..." ) // Const const ( PublicConst = ... privateConst = ... ) // Variable var PublicVar ... var privateVar ... var someVar = someFunc() var someVar2 = ... // Alias type PublicType ... type privateType ... // Function func init() { someVar2... } func PublicFunc() {...} func privateFunc() {...} func someFunc() {...} // Struct & Method type PublicStruct struct{ PublicField ... privateField ... } func (s PublicStruct) PublicMethod() {...} func (s PublicStruct) privateMethod() {...} type privateStruct struct{ PrivateField ... // field가 대문자로 시작해도 구조체가 소문자로 시작해서 private privateField ... } func (s privateStruct) PrivateMethod() {...} // method가 대문자로 시작해도 구조체가 소문자로 시작해서 private
ㅡㅡ hello.go
package main import ( "hello/pkg1" "github.com/.../pkg2" "github.com/.../pkg3" "..." ) func main() { ... pkg1.PublicFunc() pkg2.어쩌구함수() pkg3.저쩌구함수() ... }
ㅡㅡ go.sum (go mod tidy으로 생성됨)
ㅡㅡ hello.exe (마지막에 go build로 생성됨)
패키지 종류
- Go언어에서 기본 제공
- 깃허브 등 외부 저장소에 존재
- 현재 폴더 하위에 존재
'컴퓨터과학 > 기타' 카테고리의 다른 글
WSL 활성화 ↔ VT-x/EPT or AMD-V/RVI 활성화 전환 (0) | 2024.07.23 |
---|---|
VMware Ubuntu 브릿지 설정 방법 (2) | 2024.07.20 |
[Windows test mode] (0) | 2024.07.15 |
[Windows VM 오류 @ Virtualbox] 부팅 실패, Windows cannot read the <ProductKey> ... (0) | 2024.04.12 |