How do you specify a specific version of a dependency using Go Modules?
- Using the 'require' directive
- Using the 'replace' directive
- Using the 'exclude' directive
- Using the 'import' directive
To specify a specific version of a dependency using Go Modules, you use the 'require' directive in the go.mod file. You list the module path and the desired version, ensuring that the version adheres to semantic versioning (SemVer). This allows Go Modules to fetch the correct version of the dependency when you build your project. This precise versioning is essential for ensuring consistency and predictability in your project's dependencies.
Loading...
Related Quiz
- JSON encoding in Go can be performed using the _____ package.
- Explain a situation where dependency injection could simplify the process of mocking external services in a Go application.
- How would you optimize the performance of a Go program based on profiling data?
- The _____ tool can be used to analyze the performance of Go code line-by-line.
- How do you synchronize goroutines in Go?