Go

Go Modules

go.mod, go.sum, versioning, dependencies, go get, go mod tidy, replace directives

18 câu hỏi phỏng vấn·
Mid-Level
1

What is go.mod in a Go project?

Câu trả lời

The go.mod file is the Go module definition file. It contains the module name, required Go version and the list of direct dependencies with their versions. It is created with 'go mod init' and enables deterministic dependency management, unlike the old GOPATH.

2

What is the role of the go.sum file?

Câu trả lời

The go.sum file contains cryptographic checksums (hashes) of all direct and indirect dependencies. It ensures build integrity and reproducibility by verifying that downloaded dependencies have not been modified. Unlike go.mod which only lists direct dependencies, go.sum includes all transitive dependencies.

3

How to initialize a new Go module in a project?

Câu trả lời

The command 'go mod init <module_name>' initializes a new module by creating the go.mod file. The module name is usually the repository path (e.g. github.com/user/project). This command should be executed at the project root, only once when creating the module.

4

What does the 'go mod tidy' command do?

5

What is the semantic versioning syntax in go.mod?

+15 câu hỏi phỏng vấn

Nắm vững Go cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí