diff --git a/100_errors_go/interfaces/main.go b/100_errors_go/interfaces/main.go new file mode 100644 index 0000000..d3ca4f3 --- /dev/null +++ b/100_errors_go/interfaces/main.go @@ -0,0 +1,72 @@ +package main + +BAD +// Producer + +type CustomerStorage interface { + StoreCustomer(customer string) error + GetCustomer(is string) error + UpdateCustomer(customer string) error + GetAllCustomers() ([]string,error) + GetCustomerWithoutContract() ([]string,error) +} + +//====================================== + + +// Consumer + +type customerGetter interface { + GetAllCustomers() ([]string,error) +} + + + +//=================================================================== + +type IntConfig struct { + // ... +} + +func (c IntConfig) Get() int { <======== PRODUCER + return 0 +} + +func (c IntConfig) Set(value int) { + //... +} + + + +Consumer + +type confifSetter interface{ + Set() +} + +type configGetter interface { + Get() int +} + +type Mixed interface { + confifSetter + configGetter +} + + + + + + + +type Foo struct { + threshold configGetter +} + +func NewFoo(new_threshold configGetter) Foo { + return Foo{threshold: new_threshold} +} + +func (f Foo) Bar() { + threshold := f.threshold.Get() +} diff --git a/goroutines/go.mod b/goroutines/go.mod new file mode 100644 index 0000000..454ddb6 --- /dev/null +++ b/goroutines/go.mod @@ -0,0 +1,3 @@ +module main + +go 1.25.6 diff --git a/goroutines/main.go b/goroutines/main.go new file mode 100644 index 0000000..ed9d8d5 --- /dev/null +++ b/goroutines/main.go @@ -0,0 +1,19 @@ +package main + +import "fmt" + +func Route(i int, ch chan<- int) { + ch <- i +} + +func main() { + ch := make(chan int) + + for i:= range 10 { + go Route(i, ch) + } + + for i := range ch { + fmt.Println(i) + } +} diff --git a/rbd_exporter/main.go b/rbd_exporter/main.go index b2456b9..e1332ff 100644 --- a/rbd_exporter/main.go +++ b/rbd_exporter/main.go @@ -78,6 +78,7 @@ func main() { // HTTP runs in separate thread cuz it blocks further execution of main go func() { + fmt.Fprint() mainlogger.Info("Starting http server") // Here I check for errors if HTTP fails if err := server.ListenAndServe(); err != nil {