mirror of
https://github.com/SourceFellows/gobuch.git
synced 2024-12-26 11:31:42 +00:00
Verlinkungen zu Beispielen eingefügt.
This commit is contained in:
parent
264c517cec
commit
ee1ecf0924
150
README.md
150
README.md
@ -3,3 +3,153 @@
|
||||
Das Repository beinhaltet die Codebeispiele für das Buch `Microservices mit Go` des Rheinwerk Verlags:
|
||||
|
||||
https://www.rheinwerk-verlag.de/microservices-mit-go-konzepte-werkzeuge-best-practices/
|
||||
|
||||
Der aktuelle Stand befinden sich immer unter: https://github.com/SourceFellows/gobuch
|
||||
|
||||
## Beispiele
|
||||
|
||||
Folgende Beispielprojekte sind in diesem Repository enthalten:
|
||||
|
||||
* 1 Einführung
|
||||
* [cplusplus](hello-world/cplusplus)
|
||||
* [go](hello-world/go)
|
||||
* [java](hello-world/java)
|
||||
* [javascript](hello-world/javascript)
|
||||
* [python](hello-world/python)
|
||||
* [typescript](hello-world/typescript)
|
||||
* [hello-interface](hello-interface)
|
||||
* [hello-channel](hello-channel)
|
||||
* [hello-go-channel](hello-go-channel)
|
||||
* [hello-channel-post](hello-channel-post)
|
||||
|
||||
* 2 Die Grundlagen von Go
|
||||
* [collection-array](go-language-sample/collection-array)
|
||||
* [collection-array-slice](go-language-sample/collection-array-slice)
|
||||
* [collection-capa](go-language-sample/collection-capa)
|
||||
* [collection-for-range](go-language-sample/collection-for-range)
|
||||
* [defer](go-language-sample/defer)
|
||||
* [defer-file-open](go-language-sample/defer-file-open)
|
||||
* [defer-lock](go-language-sample/defer-lock)
|
||||
* [errors](go-language-sample/errors)
|
||||
* [errors-new](go-language-sample/errors-new)
|
||||
* [errors-owntyp](go-language-sample/errors-owntyp)
|
||||
* [errors-owntyp-wrap](go-language-sample/errors-owntyp-wrap)
|
||||
* [fmt-package](go-language-sample/fmt-package)
|
||||
* [for-range](go-language-sample/for-range)
|
||||
* [pointer](go-language-sample/pointer)
|
||||
* [pointer-parameter](go-language-sample/pointer-parameter)
|
||||
* [pointer-receiver](go-language-sample/pointer-receiver)
|
||||
* [pointer-struct](go-language-sample/pointer-struct)
|
||||
* [sampledoc](go-language-sample/sampledoc)
|
||||
* [switch-case](go-language-sample/switch-case)
|
||||
* [switch-case-falltrough](go-language-sample/switch-case-falltrough)
|
||||
* [switch-case-no-expression](go-language-sample/switch-case-no-expression)
|
||||
* [type-alias-definition](go-language-sample/type-alias-definition)
|
||||
* [type-definition](go-language-sample/type-definition)
|
||||
* [type-definition-assertion](go-language-sample/type-definition-assertion)
|
||||
* [type-definition-interface](go-language-sample/type-definition-interface)
|
||||
* [type-definition-interface-receiver](go-language-sample/type-definition-interface-receiver)
|
||||
* [type-definition-struct](go-language-sample/type-definition-struct)
|
||||
* [type-definition-switch](go-language-sample/type-definition-switch)
|
||||
* [type-failure](go-language-sample/type-failure)
|
||||
* [varadic-parameter](go-language-sample/varadic-parameter)
|
||||
* [somelib](somelib)
|
||||
* [vscode-first](vscode-first)
|
||||
* [first-module-dependency](first-module-dependency)
|
||||
* [library-dependency](library-dependency)
|
||||
* [module-logrus](module-logrus)
|
||||
|
||||
* 3 Microservices
|
||||
* [container](microservices/container)
|
||||
* [default-mux-demo](microservices/default-mux-demo)
|
||||
* [formrequest](microservices/formrequest)
|
||||
* [go-channel](microservices/go-channel)
|
||||
* [gorilla-mux](microservices/gorilla-mux)
|
||||
* [gorm](microservices/gorm)
|
||||
* [gorm-hooks](microservices/gorm-hooks)
|
||||
* [gorm-relation](microservices/gorm-relation)
|
||||
* [grpc](microservices/grpc)
|
||||
* [hanlder-impl](microservices/hanlder-impl)
|
||||
* [http-client](microservices/http-client)
|
||||
* [http-client-circut-breaker](microservices/http-client-circut-breaker)
|
||||
* [http-client-config](microservices/http-client-config)
|
||||
* [http-client-ssl-cert](microservices/http-client-ssl-cert)
|
||||
* [http-metod-matching](microservices/http-metod-matching)
|
||||
* [http-ratelimit](microservices/http-ratelimit)
|
||||
* [http-registration](microservices/http-registration)
|
||||
* [http-retry](microservices/http-retry)
|
||||
* [httpsserver](microservices/httpsserver)
|
||||
* [httpsservercert](microservices/httpsservercert)
|
||||
* [jsonhandling](microservices/jsonhandling)
|
||||
* [jsonservice](microservices/jsonservice)
|
||||
* [jwt](microservices/jwt)
|
||||
* [letscrypt](microservices/letscrypt)
|
||||
* [logging](microservices/logging)
|
||||
* [middleware](microservices/middleware)
|
||||
* [mongodb](microservices/mongodb)
|
||||
* [mongodb-update](microservices/mongodb-update)
|
||||
* [nats](microservices/nats)
|
||||
* [oracle-db-connection](microservices/oracle-db-connection)
|
||||
* [oracle-db-connection-prepared-statement](microservices/oracle-db-connection-prepared-statement)
|
||||
* [oracle-db-connection-write](microservices/oracle-db-connection-write)
|
||||
* [oracle-db-connection-write-tx](microservices/oracle-db-connection-write-tx)
|
||||
* [prometheus](microservices/prometheus)
|
||||
* [prometheus-metrics](microservices/prometheus-metrics)
|
||||
* [rfc7808](microservices/rfc7808)
|
||||
* [simple-http](microservices/simple-http)
|
||||
* [best-practices-generator-function](concurrency/best-practices-generator-function)
|
||||
* [best-practices-multiplexer](concurrency/best-practices-multiplexer)
|
||||
* [best-practices-multiplexer-select](concurrency/best-practices-multiplexer-select)
|
||||
* [best-practices-sync](concurrency/best-practices-sync)
|
||||
* [best-practices-timeout](concurrency/best-practices-timeout)
|
||||
* [channel-mit-close](concurrency/channel-mit-close)
|
||||
* [channel-range](concurrency/channel-range)
|
||||
* [channels](concurrency/channels)
|
||||
* [first-go-routine](concurrency/first-go-routine)
|
||||
* [first-go-routine-mit-channel](concurrency/first-go-routine-mit-channel)
|
||||
* [graceful-shutdown](concurrency/graceful-shutdown)
|
||||
* [java-threads-beispiel](concurrency/java-threads-beispiel)
|
||||
* [application-configuration](configuration/application-configuration)
|
||||
* [application-configuration-os](configuration/application-configuration-os)
|
||||
* [application-configuration-viper](configuration/application-configuration-viper)
|
||||
|
||||
* 4 Die Qualitätssicherung
|
||||
* [http-server-test](quality/http-server-test)
|
||||
* [http-server-test.v1](quality/http-server-test.v1)
|
||||
* [http-server-test.v2](quality/http-server-test.v2)
|
||||
* [http-server-test.v3](quality/http-server-test.v3)
|
||||
* [unittest](quality/unittest)
|
||||
|
||||
* 5 Best Practices – idiomatisches und effektives Go
|
||||
* [context](best-practices/context)
|
||||
* [context-http-server](best-practices/context-http-server)
|
||||
* [context-loop](best-practices/context-loop)
|
||||
* [context-value](best-practices/context-value)
|
||||
* [context-value-nono](best-practices/context-value-nono)
|
||||
* [empty-string-check](best-practices/empty-string-check)
|
||||
* [error-behaviour](best-practices/error-behaviour)
|
||||
* [error-handling](best-practices/error-handling)
|
||||
* [error-handling-2](best-practices/error-handling-2)
|
||||
* [error-handling-3](best-practices/error-handling-3)
|
||||
* [file-io](best-practices/file-io)
|
||||
* [file-io-large](best-practices/file-io-large)
|
||||
* [force-interface](best-practices/force-interface)
|
||||
* [goroutine-pooling](best-practices/goroutine-pooling)
|
||||
* [logging-defer](best-practices/logging-defer)
|
||||
* [map-contains](best-practices/map-contains)
|
||||
* [project-structure](best-practices/project-structure)
|
||||
* [single-method-interface](best-practices/single-method-interface)
|
||||
* [struct-to-text](best-practices/struct-to-text)
|
||||
* [synchron-api](best-practices/synchron-api)
|
||||
|
||||
* 6 Go-Service an die Cloud anbinden
|
||||
* [aws-beanstak-sample](cloud-provider/aws-beanstak-sample)
|
||||
* [aws-lambda-go](cloud-provider/aws-lambda-go)
|
||||
* [azure-kubernetes](cloud-provider/azure-kubernetes)
|
||||
* [docker-compose](cloud-provider/docker-compose)
|
||||
* [docker-sample](cloud-provider/docker-sample)
|
||||
* [docker-sample-multistage](cloud-provider/er-sample-multistage)
|
||||
* [go-cloud](cloud-provider/go-cloud)
|
||||
* [google-cloud-hello](cloud-provider/google-cloud-hello)
|
||||
* [google-cloud-sample](cloud-provider/google-cloud-sample)
|
||||
* [minikube-sample](cloud-provider/minikube-sample)
|
||||
|
@ -8,9 +8,22 @@ type Tester struct {
|
||||
Sonstwas string
|
||||
}
|
||||
|
||||
type StringTester struct {
|
||||
Name string
|
||||
Alter int
|
||||
Sonstwas string
|
||||
}
|
||||
|
||||
func (st *StringTester) String() string {
|
||||
return fmt.Sprintf("StringTester %v, Alter: %v", st.Name, st.Alter)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
t := &Tester{Name: "Dingo", Alter: 3, Sonstwas: "Wert"}
|
||||
fmt.Printf("%+v\n", t)
|
||||
|
||||
st := &StringTester{Name: "Dingo", Alter: 3, Sonstwas: "Wert"}
|
||||
fmt.Printf("%+v\n", st)
|
||||
|
||||
}
|
||||
|
7
golang-language-samples/fmt-package/main.go
Normal file
7
golang-language-samples/fmt-package/main.go
Normal file
@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Hello %q", "hello")
|
||||
}
|
12
golang-language-samples/varadic-parameter/main.go
Normal file
12
golang-language-samples/varadic-parameter/main.go
Normal file
@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func something(text string, i ...int) int {
|
||||
fmt.Println(i[0])
|
||||
return i[1]
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(something("hello", 1, 2))
|
||||
}
|
@ -1,10 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Testing struct {
|
||||
Val1 bool
|
||||
Val2 string
|
||||
Val3 time.Time
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
log.SetFormatter(&log.JSONFormatter{})
|
||||
|
||||
// zusätzliche Felder an log.Entry anhängen
|
||||
log.WithFields(log.Fields{
|
||||
"importId": "ka18s",
|
||||
@ -15,6 +26,7 @@ func main() {
|
||||
contextLogger := log.WithFields(log.Fields{
|
||||
"importId": "0815s",
|
||||
"other": "Ich werde geloggt",
|
||||
"test": Testing{Val3: time.Now()},
|
||||
})
|
||||
contextLogger.Info("I'll be logged with common and other field")
|
||||
contextLogger.Info("Me too")
|
||||
|
Loading…
Reference in New Issue
Block a user