Last active
January 31, 2022 23:39
-
-
Save ihcsim/77882fa59e9a5e16e9737ab41021f5d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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