This file contains hidden or 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 Car interface { | |
| Drive() string | |
| } | |
| type SportsCar struct {} | |
| func (s SportsCar) Drive() string { | |
| return "Vroom vroom!" | |
| } |
This file contains hidden or 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
| config, err := clientcmd.BuildConfigFromFlags("", "~/.kube/config") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| clientset, err := kubernetes.NewForConfig(config) | |
| if err != nil { | |
| log.Fatal(err) | |
| } |
This file contains hidden or 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
| conn, err := net.Dial("tcp", "www.google.com:80") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| defer conn.Close() |
This file contains hidden or 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 Car interface { | |
| Drive() string | |
| } | |
| type SportsCar struct {} | |
| func (s SportsCar) Drive() string { | |
| return "Vroom vroom!" | |
| } |
This file contains hidden or 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
| p := NewPerson(func(p *Person) { | |
| p.Name = "John" | |
| p.Age = 25 | |
| p.Address = "123 Main St" | |
| p.Phone = "555-555-5555" | |
| p.Email = "[email protected]" | |
| }) |
This file contains hidden or 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
| func NewPerson(builder func(p *Person)) *Person { | |
| person := &Person{} | |
| builder(person) | |
| return person | |
| } |
This file contains hidden or 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
| func main() { | |
| person := NewPersonBuilder(). | |
| WithName("John"). | |
| WithAge(25). | |
| WithAddress("123 Main St"). | |
| WithPhone("555-555-5555"). | |
| WithEmail("[email protected]"). | |
| Build() | |
| } |
This file contains hidden or 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 PersonBuilder struct { | |
| person Person | |
| } | |
| func NewPersonBuilder() *PersonBuilder { | |
| return &PersonBuilder{ | |
| person: Person{}, | |
| } | |
| } |
This file contains hidden or 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 Person struct { | |
| Name string | |
| Age int | |
| Address string | |
| Phone string | |
| Email string | |
| } |
This file contains hidden or 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
| package main | |
| import ( | |
| "github.com/go-logr/logr" | |
| "sigs.k8s.io/controller-runtime/pkg/client" | |
| "sigs.k8s.io/controller-runtime/pkg/controller" | |
| "sigs.k8s.io/controller-runtime/pkg/handler" | |
| "sigs.k8s.io/controller-runtime/pkg/source" | |
| ) |