DevOps resource struct module
How to import module for the resources built in go:
Example in how the import is call in your go code:
import "github.com/liatrio/devops-bootcamp/examples/ch7/devops-resources"
This is how you would pull the module in the default branch [master]
If you are trying to pull the module from a branch that differs from the default branch then you can do this step:
require github.com/liatrio/devops-bootcamp/examples/ch7/devops-resource [branch]
When you run go mod tidy go will look for the module at the head of the branch you specified in go.mod
How to call package devops_resource:
To access struct type that is defined in the module you call it like this:
Engineer Struct:
devops_resource.Engineer
Dev Struct:
devops_resource.Dev
Ops Struct:
devops_resource.Ops
DevOps Struct:
devops_resource.DevOps
Notes:
The structs use references of another struct object to manage lists.
- This allows easier management of the lists when updating a resource.
Struct Example:
type DevOps struct {
Id string `json:"id"`
Devs []*Dev `json:"dev"`
Ops []*Ops `json:"ops"`
}
DevOps Struct is a good example of this since it manages a list of type Dev and Ops.
Why is the module name long and almost looks like a path.
- Go looks for the path in which the package and module is referenced.
- For this case the repository is github.com(host)/liatrio(owner)/devops-bootcamp(repo)/examples/ch7/devops-resources(path to package)