Please enable JavaScript.
Coggle requires JavaScript to display documents.
Go Modules - Coggle Diagram
Go Modules
How to keep your module compatible
function
Pass the context as first argument of function
add optional argument for future
"Option types" pattern
adding configuration methods
Adding variadic parameters to your exist function
self-referential function for config
struct
prevent to add uncomparable property like slice, map, func
interface
prevent to return interface type, you should return concrete type
Debug incompatible package when upgrade
go mod why -m <package name>
go mod graph | grep <package name>
How to upgrade to go module
godeps: just go mod init and the go modules will automatically import
go mod init and run go mod tidy
Version module
unstable: v0.1.0
stable version: v1.0.0
Semantic Import Version
gopkg.in/yml.v1 and gopkg.in/yml.v2
if not gopkg.in must be /v1 and /v2 ending
Begin: version 1.11 of Golang
Init: go mod init <package name>
List all modules and its dependencies: go mod -m all
Require package: go get <package name>
<branch/hash
: commit/version>
Cleanup unused dependencies: go mod tidy
//indirect mean the imported package not migrated to module yet
Make new version by copy all *.go file to v2 folder
Non-breacking changes: add not remove or edit