Skip to content

Instantly share code, notes, and snippets.

@ihcsim
Last active January 31, 2022 23:39
Show Gist options
  • Save ihcsim/77882fa59e9a5e16e9737ab41021f5d4 to your computer and use it in GitHub Desktop.
Save ihcsim/77882fa59e9a5e16e9737ab41021f5d4 to your computer and use it in GitHub Desktop.
type Service struct {
name string
namespace string
endpoints []string
mappings map[string]string
}
func main() {
svc := Service{
name: "nginx",
namespace: "default",
endpoints: []string{
"192.168.0.1",
"192.168.0.2",
},
mappings: map[string]string{
"pod-0": "192.168.0.1",
"pod-1": "192.168.0.2",
},
}
nginx := svc
nginx.namespace = "ingress"
nginx.endpoints = append(nginx.endpoints, "192.168.0.40")
nginx.mappings["pod-2"] = "192.168.0.40"
fmt.Printf("updated: %+v\noriginal: %+v\n", nginx, svc)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment