diff --git a/14_protocolbuffers/pb/example_01/go.mod b/14_protocolbuffers/pb/example_01/go.mod index bf00e32..7575b00 100644 --- a/14_protocolbuffers/pb/example_01/go.mod +++ b/14_protocolbuffers/pb/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_01 go 1.15 diff --git a/14_protocolbuffers/pb/example_01/main.go b/14_protocolbuffers/pb/example_01/main.go index 80daa40..307975a 100644 --- a/14_protocolbuffers/pb/example_01/main.go +++ b/14_protocolbuffers/pb/example_01/main.go @@ -1,26 +1,25 @@ package main import ( - "fmt" - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_01/user" - "google.golang.org/protobuf/proto" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_01/user" + "google.golang.org/protobuf/proto" ) func main() { - u := user.User{Email:"john@gmail.com", UserId: "John"} + u := user.User{Email: "john@gmail.com", UserId: "John"} - fmt.Println("To encode:", u.String()) - encoded, err := proto.Marshal(&u) - if err != nil { - panic(err) - } + fmt.Println("To encode:", u.String()) + encoded, err := proto.Marshal(&u) + if err != nil { + panic(err) + } - v := user.User{} - err = proto.Unmarshal(encoded, &v) - if err != nil { - panic(err) - } - fmt.Println("Recovered:", v.String()) + v := user.User{} + err = proto.Unmarshal(encoded, &v) + if err != nil { + panic(err) + } + fmt.Println("Recovered:", v.String()) } - - diff --git a/14_protocolbuffers/pb/example_01/user.proto b/14_protocolbuffers/pb/example_01/user.proto index b605262..d20e834 100644 --- a/14_protocolbuffers/pb/example_01/user.proto +++ b/14_protocolbuffers/pb/example_01/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_01/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_01/user"; message User { string user_id = 1; diff --git a/14_protocolbuffers/pb/example_02/go.mod b/14_protocolbuffers/pb/example_02/go.mod index bb0532f..71fe726 100644 --- a/14_protocolbuffers/pb/example_02/go.mod +++ b/14_protocolbuffers/pb/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_02 go 1.15 diff --git a/14_protocolbuffers/pb/example_02/main.go b/14_protocolbuffers/pb/example_02/main.go index 31282a1..eec5443 100644 --- a/14_protocolbuffers/pb/example_02/main.go +++ b/14_protocolbuffers/pb/example_02/main.go @@ -1,29 +1,28 @@ package main import ( - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_02/user" - "google.golang.org/protobuf/proto" - "fmt" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_02/user" + "google.golang.org/protobuf/proto" ) func main() { - userA := user.User{UserId: "John", Email: "john@gmail.com"} - userB := user.User{UserId: "Mary", Email:"mary@gmail.com"} + userA := user.User{UserId: "John", Email: "john@gmail.com"} + userB := user.User{UserId: "Mary", Email: "mary@gmail.com"} - g := user.Group{Id: 1, - Score: 42.0, - Category: user.Category_DEVELOPER, - Users: []*user.User{&userA,&userB}, - } - fmt.Println("To encode:", g.String()) + g := user.Group{Id: 1, + Score: 42.0, + Category: user.Category_DEVELOPER, + Users: []*user.User{&userA, &userB}, + } + fmt.Println("To encode:", g.String()) - encoded, err := proto.Marshal(&g) - if err != nil { - panic(err) - } - recovered := user.Group{} - err = proto.Unmarshal(encoded, &recovered) - fmt.Println("Recovered:", recovered.String()) + encoded, err := proto.Marshal(&g) + if err != nil { + panic(err) + } + recovered := user.Group{} + err = proto.Unmarshal(encoded, &recovered) + fmt.Println("Recovered:", recovered.String()) } - - diff --git a/14_protocolbuffers/pb/example_02/user.proto b/14_protocolbuffers/pb/example_02/user.proto index 445c137..1b81dcb 100644 --- a/14_protocolbuffers/pb/example_02/user.proto +++ b/14_protocolbuffers/pb/example_02/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_02/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_02/user"; message User { string user_id = 1; diff --git a/14_protocolbuffers/pb/example_03/go.mod b/14_protocolbuffers/pb/example_03/go.mod index 1a8c67f..0add49d 100644 --- a/14_protocolbuffers/pb/example_03/go.mod +++ b/14_protocolbuffers/pb/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_03 go 1.15 diff --git a/14_protocolbuffers/pb/example_03/group.proto b/14_protocolbuffers/pb/example_03/group.proto index 8c402f8..20bac97 100644 --- a/14_protocolbuffers/pb/example_03/group.proto +++ b/14_protocolbuffers/pb/example_03/group.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package group; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_03/group"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_03/group"; import "user.proto"; diff --git a/14_protocolbuffers/pb/example_03/group/group.pb.go b/14_protocolbuffers/pb/example_03/group/group.pb.go index 943bd45..b35a787 100644 --- a/14_protocolbuffers/pb/example_03/group/group.pb.go +++ b/14_protocolbuffers/pb/example_03/group/group.pb.go @@ -8,7 +8,7 @@ package group import ( proto "github.com/golang/protobuf/proto" - user "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_03/user" + user "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_03/user" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" diff --git a/14_protocolbuffers/pb/example_03/main.go b/14_protocolbuffers/pb/example_03/main.go index d2dd23f..1405613 100644 --- a/14_protocolbuffers/pb/example_03/main.go +++ b/14_protocolbuffers/pb/example_03/main.go @@ -1,30 +1,29 @@ package main import ( - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_03/group" - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_03/user" - "google.golang.org/protobuf/proto" - "fmt" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_03/group" + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_03/user" + "google.golang.org/protobuf/proto" ) func main() { - userA := user.User{UserId: "John", Email: "john@gmail.com"} - userB := user.User{UserId: "Mary", Email:"mary@gmail.com"} + userA := user.User{UserId: "John", Email: "john@gmail.com"} + userB := user.User{UserId: "Mary", Email: "mary@gmail.com"} - g := group.Group{Id: 1, - Score: 42.0, - Category: group.Category_DEVELOPER, - Users: []*user.User{&userA,&userB}, - } - fmt.Println("To encode:", g.String()) + g := group.Group{Id: 1, + Score: 42.0, + Category: group.Category_DEVELOPER, + Users: []*user.User{&userA, &userB}, + } + fmt.Println("To encode:", g.String()) - encoded, err := proto.Marshal(&g) - if err != nil { - panic(err) - } - recovered := group.Group{} - err = proto.Unmarshal(encoded, &recovered) - fmt.Println("Recovered:", recovered.String()) + encoded, err := proto.Marshal(&g) + if err != nil { + panic(err) + } + recovered := group.Group{} + err = proto.Unmarshal(encoded, &recovered) + fmt.Println("Recovered:", recovered.String()) } - - diff --git a/14_protocolbuffers/pb/example_03/user.proto b/14_protocolbuffers/pb/example_03/user.proto index b8097b9..7615e66 100644 --- a/14_protocolbuffers/pb/example_03/user.proto +++ b/14_protocolbuffers/pb/example_03/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_03/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_03/user"; message User { string user_id = 1; diff --git a/14_protocolbuffers/pb/example_04/go.mod b/14_protocolbuffers/pb/example_04/go.mod index 548f930..d8f684b 100644 --- a/14_protocolbuffers/pb/example_04/go.mod +++ b/14_protocolbuffers/pb/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_04 go 1.15 diff --git a/14_protocolbuffers/pb/example_04/group.proto b/14_protocolbuffers/pb/example_04/group.proto index afe8260..097c8bc 100644 --- a/14_protocolbuffers/pb/example_04/group.proto +++ b/14_protocolbuffers/pb/example_04/group.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package group; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_04/group"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_04/group"; enum Category { DEVELOPER = 0; diff --git a/14_protocolbuffers/pb/example_04/main.go b/14_protocolbuffers/pb/example_04/main.go index 98af3de..76108a0 100644 --- a/14_protocolbuffers/pb/example_04/main.go +++ b/14_protocolbuffers/pb/example_04/main.go @@ -1,28 +1,28 @@ package main + import ( - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_04/group" - "google.golang.org/protobuf/proto" - "fmt" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_04/group" + "google.golang.org/protobuf/proto" ) func main() { - userA := group.Group_User{UserId: "John", Email: "john@gmail.com"} - userB := group.Group_User{UserId: "Mary", Email:"mary@gmail.com"} + userA := group.Group_User{UserId: "John", Email: "john@gmail.com"} + userB := group.Group_User{UserId: "Mary", Email: "mary@gmail.com"} - g := group.Group{Id: 1, - Score: 42.0, - Category: group.Category_DEVELOPER, - Users: []*group.Group_User{&userA, &userB}, - } - fmt.Println("To encode:", g.String()) + g := group.Group{Id: 1, + Score: 42.0, + Category: group.Category_DEVELOPER, + Users: []*group.Group_User{&userA, &userB}, + } + fmt.Println("To encode:", g.String()) - encoded, err := proto.Marshal(&g) - if err != nil { - panic(err) - } - recovered := group.Group{} - err = proto.Unmarshal(encoded, &recovered) - fmt.Println("Recovered:", recovered.String()) + encoded, err := proto.Marshal(&g) + if err != nil { + panic(err) + } + recovered := group.Group{} + err = proto.Unmarshal(encoded, &recovered) + fmt.Println("Recovered:", recovered.String()) } - - diff --git a/14_protocolbuffers/pb/example_05/go.mod b/14_protocolbuffers/pb/example_05/go.mod index 1861253..5a91c02 100644 --- a/14_protocolbuffers/pb/example_05/go.mod +++ b/14_protocolbuffers/pb/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_05 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_05 go 1.15 diff --git a/14_protocolbuffers/pb/example_05/main.go b/14_protocolbuffers/pb/example_05/main.go index 0eb6659..17d8e00 100644 --- a/14_protocolbuffers/pb/example_05/main.go +++ b/14_protocolbuffers/pb/example_05/main.go @@ -1,25 +1,24 @@ package main import ( - "fmt" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_05/user" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_05/user" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" ) func main() { - info := anypb.Any{Value: []byte(`John rules`), TypeUrl: "urltype"} - userA := user.User{UserId: "John", Email: "john@gmail.com", Info: []*anypb.Any{&info}} - anypb.a - fmt.Println("To encode:", userA.String()) + info := anypb.Any{Value: []byte(`John rules`), TypeUrl: "urltype"} + userA := user.User{UserId: "John", Email: "john@gmail.com", Info: []*anypb.Any{&info}} + anypb.a + fmt.Println("To encode:", userA.String()) - encoded, err := proto.Marshal(&userA) - if err != nil { - panic(err) - } - recovered := user.User{} - err = proto.Unmarshal(encoded, &recovered) - fmt.Println("Recovered:", recovered.String()) + encoded, err := proto.Marshal(&userA) + if err != nil { + panic(err) + } + recovered := user.User{} + err = proto.Unmarshal(encoded, &recovered) + fmt.Println("Recovered:", recovered.String()) } - - diff --git a/14_protocolbuffers/pb/example_05/user.proto b/14_protocolbuffers/pb/example_05/user.proto index d192c97..c33abeb 100644 --- a/14_protocolbuffers/pb/example_05/user.proto +++ b/14_protocolbuffers/pb/example_05/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_05/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_05/user"; import "google/protobuf/any.proto"; diff --git a/14_protocolbuffers/pb/example_06/go.mod b/14_protocolbuffers/pb/example_06/go.mod index 1cb71ff..3652a5f 100644 --- a/14_protocolbuffers/pb/example_06/go.mod +++ b/14_protocolbuffers/pb/example_06/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_06 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_06 go 1.15 diff --git a/14_protocolbuffers/pb/example_06/main.go b/14_protocolbuffers/pb/example_06/main.go index aa69f2f..6904400 100644 --- a/14_protocolbuffers/pb/example_06/main.go +++ b/14_protocolbuffers/pb/example_06/main.go @@ -1,39 +1,38 @@ package main import ( - "fmt" - "google.golang.org/protobuf/proto" - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_06/user" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_06/user" + "google.golang.org/protobuf/proto" ) func main() { - goDeveloper := user.Developer{Language: "go"} - userA := user.User{UserId: "John", Email: "john@gmail.com", - Type: &user.User_Developer{&goDeveloper}} - aksOperator := user.Operator{Platform: "aks"} - userB := user.User{UserId: "Mary", Email: "mary@gmail.com", - Type: &user.User_Operator{&aksOperator}} + goDeveloper := user.Developer{Language: "go"} + userA := user.User{UserId: "John", Email: "john@gmail.com", + Type: &user.User_Developer{&goDeveloper}} + aksOperator := user.Operator{Platform: "aks"} + userB := user.User{UserId: "Mary", Email: "mary@gmail.com", + Type: &user.User_Operator{&aksOperator}} - encodedA, err := proto.Marshal(&userA) - if err != nil { - panic(err) - } - encodedB, err := proto.Marshal(&userB) - if err != nil { - panic(err) - } + encodedA, err := proto.Marshal(&userA) + if err != nil { + panic(err) + } + encodedB, err := proto.Marshal(&userB) + if err != nil { + panic(err) + } - recoveredA, recoveredB := user.User{}, user.User{} - err = proto.Unmarshal(encodedA, &recoveredA) - if err != nil { - panic(err) - } - err = proto.Unmarshal(encodedB, &recoveredB) - if err != nil { - panic(err) - } - fmt.Println("RecoveredA:", recoveredA.String()) - fmt.Println("RecoveredB:", recoveredB.String()) + recoveredA, recoveredB := user.User{}, user.User{} + err = proto.Unmarshal(encodedA, &recoveredA) + if err != nil { + panic(err) + } + err = proto.Unmarshal(encodedB, &recoveredB) + if err != nil { + panic(err) + } + fmt.Println("RecoveredA:", recoveredA.String()) + fmt.Println("RecoveredB:", recoveredB.String()) } - - diff --git a/14_protocolbuffers/pb/example_06/user.proto b/14_protocolbuffers/pb/example_06/user.proto index 5dd86e4..259d1d5 100644 --- a/14_protocolbuffers/pb/example_06/user.proto +++ b/14_protocolbuffers/pb/example_06/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_06/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_06/user"; message Developer { string language = 1; diff --git a/14_protocolbuffers/pb/example_07/go.mod b/14_protocolbuffers/pb/example_07/go.mod index 1228852..c06ee85 100644 --- a/14_protocolbuffers/pb/example_07/go.mod +++ b/14_protocolbuffers/pb/example_07/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_07 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_07 go 1.15 diff --git a/14_protocolbuffers/pb/example_07/main.go b/14_protocolbuffers/pb/example_07/main.go index d9e653b..f3a76e5 100644 --- a/14_protocolbuffers/pb/example_07/main.go +++ b/14_protocolbuffers/pb/example_07/main.go @@ -1,34 +1,33 @@ package main import ( - "fmt" - "google.golang.org/protobuf/proto" - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_07/user" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_07/user" + "google.golang.org/protobuf/proto" ) func main() { - userA := user.User{UserId: "John", Email: "john@gmail.com"} - userB := user.User{UserId: "Mary", Email: "mary@gmail.com"} - - teams := map[string]*user.UserList { - "teamA": &user.UserList{Users:[]*user.User{&userA,&userB}}, - "teamB": nil, - } - - teamsPB := user.Teams{Teams: teams} - - fmt.Println("To encode:", teamsPB.String()) - - encoded, err := proto.Marshal(&teamsPB) - if err != nil { - panic(err) - } - recovered := user.Teams{} - err = proto.Unmarshal(encoded, &recovered) - if err != nil { - panic(err) - } - fmt.Println("Recovered:", recovered.String()) + userA := user.User{UserId: "John", Email: "john@gmail.com"} + userB := user.User{UserId: "Mary", Email: "mary@gmail.com"} + + teams := map[string]*user.UserList{ + "teamA": &user.UserList{Users: []*user.User{&userA, &userB}}, + "teamB": nil, + } + + teamsPB := user.Teams{Teams: teams} + + fmt.Println("To encode:", teamsPB.String()) + + encoded, err := proto.Marshal(&teamsPB) + if err != nil { + panic(err) + } + recovered := user.Teams{} + err = proto.Unmarshal(encoded, &recovered) + if err != nil { + panic(err) + } + fmt.Println("Recovered:", recovered.String()) } - - diff --git a/14_protocolbuffers/pb/example_07/user.proto b/14_protocolbuffers/pb/example_07/user.proto index 80e4d98..1689578 100644 --- a/14_protocolbuffers/pb/example_07/user.proto +++ b/14_protocolbuffers/pb/example_07/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_07/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_07/user"; message User { string user_id = 1; diff --git a/14_protocolbuffers/pb/example_08/go.mod b/14_protocolbuffers/pb/example_08/go.mod index f0c86d8..a36effa 100644 --- a/14_protocolbuffers/pb/example_08/go.mod +++ b/14_protocolbuffers/pb/example_08/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_08 +module github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_08 go 1.15 diff --git a/14_protocolbuffers/pb/example_08/main.go b/14_protocolbuffers/pb/example_08/main.go index 644ca0d..1f125f0 100644 --- a/14_protocolbuffers/pb/example_08/main.go +++ b/14_protocolbuffers/pb/example_08/main.go @@ -1,32 +1,31 @@ package main import ( - "encoding/json" - "fmt" - "github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_08/user" + "encoding/json" + "fmt" + + "github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_08/user" ) func main() { - userA := user.User{UserId: "John", Email: "john@gmail.com"} - userB := user.User{UserId: "Mary", Email: "mary@gmail.com"} + userA := user.User{UserId: "John", Email: "john@gmail.com"} + userB := user.User{UserId: "Mary", Email: "mary@gmail.com"} - teams := map[string]*user.UserList { - "teamA": &user.UserList{Users:[]*user.User{&userA,&userB}}, - "teamB": nil, - } + teams := map[string]*user.UserList{ + "teamA": &user.UserList{Users: []*user.User{&userA, &userB}}, + "teamB": nil, + } - teamsPB := user.Teams{Teams: teams} + teamsPB := user.Teams{Teams: teams} - encoded, err := json.Marshal(&teamsPB) - if err != nil { - panic(err) - } - recovered := user.Teams{} - err = json.Unmarshal(encoded, &recovered) - if err != nil { - panic(err) - } - fmt.Println("Recovered:", recovered.String()) + encoded, err := json.Marshal(&teamsPB) + if err != nil { + panic(err) + } + recovered := user.Teams{} + err = json.Unmarshal(encoded, &recovered) + if err != nil { + panic(err) + } + fmt.Println("Recovered:", recovered.String()) } - - diff --git a/14_protocolbuffers/pb/example_08/user.proto b/14_protocolbuffers/pb/example_08/user.proto index 8e4be46..704d1e8 100644 --- a/14_protocolbuffers/pb/example_08/user.proto +++ b/14_protocolbuffers/pb/example_08/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/12_protocolbuffers/pb/example_08/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/14_protocolbuffers/pb/example_08/user"; message User { string user_id = 1; diff --git a/15_grpc/grpc/example_01/client/client.go b/15_grpc/grpc/example_01/client/client.go index 2ec0566..a1e5b2a 100644 --- a/15_grpc/grpc/example_01/client/client.go +++ b/15_grpc/grpc/example_01/client/client.go @@ -1,29 +1,29 @@ package main import ( - "context" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01/user" - "google.golang.org/grpc" - "time" + "context" + "fmt" + "time" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01/user" + "google.golang.org/grpc" ) func main() { - conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithBlock()) - if err != nil { - panic(err) - } - defer conn.Close() + conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + panic(err) + } + defer conn.Close() - c := pb.NewUserServiceClient(conn) + c := pb.NewUserServiceClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), time.Second) - defer cancel() + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() - r, err := c.GetUser(ctx, &pb.UserRequest{UserId: "John"}) - if err != nil { - panic(err) - } - fmt.Println("Client received:", r.String()) + r, err := c.GetUser(ctx, &pb.UserRequest{UserId: "John"}) + if err != nil { + panic(err) + } + fmt.Println("Client received:", r.String()) } - diff --git a/15_grpc/grpc/example_01/go.mod b/15_grpc/grpc/example_01/go.mod index 4e7d790..c072798 100644 --- a/15_grpc/grpc/example_01/go.mod +++ b/15_grpc/grpc/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01 go 1.15 diff --git a/15_grpc/grpc/example_01/server/server.go b/15_grpc/grpc/example_01/server/server.go index 590484a..65347dd 100644 --- a/15_grpc/grpc/example_01/server/server.go +++ b/15_grpc/grpc/example_01/server/server.go @@ -1,31 +1,32 @@ package main import ( - "context" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01/user" - "google.golang.org/grpc" - "net" + "context" + "fmt" + "net" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01/user" + "google.golang.org/grpc" ) -type UserServer struct{ - pb.UnimplementedUserServiceServer +type UserServer struct { + pb.UnimplementedUserServiceServer } func (u *UserServer) GetUser(ctx context.Context, req *pb.UserRequest) (*pb.User, error) { - fmt.Println("Server received:", req.String()) - return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil + fmt.Println("Server received:", req.String()) + return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil } func main() { - lis, err := net.Listen("tcp", "localhost:50051") - if err != nil { - panic(err) - } - s := grpc.NewServer() - pb.RegisterUserServiceServer(s, &UserServer{}) + lis, err := net.Listen("tcp", "localhost:50051") + if err != nil { + panic(err) + } + s := grpc.NewServer() + pb.RegisterUserServiceServer(s, &UserServer{}) - if err := s.Serve(lis); err != nil { - panic(err) - } + if err := s.Serve(lis); err != nil { + panic(err) + } } diff --git a/15_grpc/grpc/example_01/user.proto b/15_grpc/grpc/example_01/user.proto index 2210465..0fb91bc 100644 --- a/15_grpc/grpc/example_01/user.proto +++ b/15_grpc/grpc/example_01/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01/user"; message User { string user_id = 1; diff --git a/15_grpc/interceptors/example_01/client/client.go b/15_grpc/interceptors/example_01/client/client.go index 55de08a..6e8f722 100644 --- a/15_grpc/interceptors/example_01/client/client.go +++ b/15_grpc/interceptors/example_01/client/client.go @@ -1,31 +1,31 @@ package main import ( - "context" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_01/user" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - "time" + "context" + "fmt" + "time" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_01/user" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) func main() { - conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithBlock()) - if err != nil { - panic(err) - } - defer conn.Close() + conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + panic(err) + } + defer conn.Close() - c := pb.NewUserServiceClient(conn) + c := pb.NewUserServiceClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), time.Second) - ctx = metadata.AppendToOutgoingContext(ctx, "password","go") - defer cancel() + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx = metadata.AppendToOutgoingContext(ctx, "password", "go") + defer cancel() - r, err := c.GetUser(ctx, &pb.UserRequest{UserId: "John"}) - if err != nil { - panic(err) - } - fmt.Println("Client received:", r.String()) + r, err := c.GetUser(ctx, &pb.UserRequest{UserId: "John"}) + if err != nil { + panic(err) + } + fmt.Println("Client received:", r.String()) } - diff --git a/15_grpc/interceptors/example_01/go.mod b/15_grpc/interceptors/example_01/go.mod index 29454a7..8cde9b9 100644 --- a/15_grpc/interceptors/example_01/go.mod +++ b/15_grpc/interceptors/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_01 go 1.15 diff --git a/15_grpc/interceptors/example_01/server/server.go b/15_grpc/interceptors/example_01/server/server.go index 5814854..ec8802a 100644 --- a/15_grpc/interceptors/example_01/server/server.go +++ b/15_grpc/interceptors/example_01/server/server.go @@ -3,12 +3,13 @@ package main import ( "context" "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_01/user" + "net" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_01/user" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" - "net" ) type UserServer struct { diff --git a/15_grpc/interceptors/example_01/user.proto b/15_grpc/interceptors/example_01/user.proto index 5fd1e94..06a4757 100644 --- a/15_grpc/interceptors/example_01/user.proto +++ b/15_grpc/interceptors/example_01/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_01/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_01/user"; message User { string user_id = 1; diff --git a/15_grpc/interceptors/example_02/client/client.go b/15_grpc/interceptors/example_02/client/client.go index b639ae8..db1d99f 100644 --- a/15_grpc/interceptors/example_02/client/client.go +++ b/15_grpc/interceptors/example_02/client/client.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_02/user" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" "runtime" "time" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_02/user" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) func ClientLoggerInterceptor( diff --git a/15_grpc/interceptors/example_02/go.mod b/15_grpc/interceptors/example_02/go.mod index 6ba7fc9..f0f62f6 100644 --- a/15_grpc/interceptors/example_02/go.mod +++ b/15_grpc/interceptors/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_02 go 1.15 diff --git a/15_grpc/interceptors/example_02/server/server.go b/15_grpc/interceptors/example_02/server/server.go index 9c53264..b7e99fe 100644 --- a/15_grpc/interceptors/example_02/server/server.go +++ b/15_grpc/interceptors/example_02/server/server.go @@ -1,52 +1,52 @@ package main import ( - "context" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_02/user" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - "net" + "context" + "fmt" + "net" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_02/user" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" ) -type UserServer struct{ - pb.UnimplementedUserServiceServer +type UserServer struct { + pb.UnimplementedUserServiceServer } func (u *UserServer) GetUser(ctx context.Context, req *pb.UserRequest) (*pb.User, error) { - fmt.Println("Server received:", req.String()) - return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil + fmt.Println("Server received:", req.String()) + return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil } func RequestLoggerInterceptor(ctx context.Context, - req interface{}, - info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler) (interface{}, error){ - md, found := metadata.FromIncomingContext(ctx) - if found { - os, _ := md["os"] - zone, _ := md["zone"] - fmt.Printf("Request from %s using %s\n", zone, os) - } - - h, err := handler(ctx, req) - return h, err + req interface{}, + info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler) (interface{}, error) { + md, found := metadata.FromIncomingContext(ctx) + if found { + os, _ := md["os"] + zone, _ := md["zone"] + fmt.Printf("Request from %s using %s\n", zone, os) + } + + h, err := handler(ctx, req) + return h, err } func withRequestLoggerInterceptor() grpc.ServerOption { - return grpc.UnaryInterceptor(RequestLoggerInterceptor) + return grpc.UnaryInterceptor(RequestLoggerInterceptor) } func main() { - lis, err := net.Listen("tcp", "localhost:50051") - if err != nil { - panic(err) - } - s := grpc.NewServer(withRequestLoggerInterceptor()) - pb.RegisterUserServiceServer(s, &UserServer{}) - - - if err := s.Serve(lis); err != nil { - panic(err) - } + lis, err := net.Listen("tcp", "localhost:50051") + if err != nil { + panic(err) + } + s := grpc.NewServer(withRequestLoggerInterceptor()) + pb.RegisterUserServiceServer(s, &UserServer{}) + + if err := s.Serve(lis); err != nil { + panic(err) + } } diff --git a/15_grpc/interceptors/example_02/user.proto b/15_grpc/interceptors/example_02/user.proto index a51699f..b771543 100644 --- a/15_grpc/interceptors/example_02/user.proto +++ b/15_grpc/interceptors/example_02/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/interceptors/example_02/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/interceptors/example_02/user"; message User { string user_id = 1; diff --git a/15_grpc/streaming/example_01/client/client.go b/15_grpc/streaming/example_01/client/client.go index 67d0e38..84a53ee 100644 --- a/15_grpc/streaming/example_01/client/client.go +++ b/15_grpc/streaming/example_01/client/client.go @@ -1,46 +1,46 @@ package main import ( - "context" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/streaming/example_01/numbers" - "google.golang.org/grpc" - "io" - "time" + "context" + "fmt" + "io" + "time" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/streaming/example_01/numbers" + "google.golang.org/grpc" ) func main() { - conn, err := grpc.Dial(":50051", grpc.WithInsecure(), grpc.WithBlock()) - if err != nil { - panic(err) - } - defer conn.Close() + conn, err := grpc.Dial(":50051", grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + panic(err) + } + defer conn.Close() - c := pb.NewNumServiceClient(conn) + c := pb.NewNumServiceClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) - defer cancel() + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) + defer cancel() - stream, err := c.Rnd(ctx, &pb.NumRequest{N:5, From:0, To: 100}) - if err != nil { - panic(err) - } + stream, err := c.Rnd(ctx, &pb.NumRequest{N: 5, From: 0, To: 100}) + if err != nil { + panic(err) + } - done := make(chan bool) - go func() { - for { - resp, err := stream.Recv() - if err == io.EOF { - done <- true - return - } - if err != nil { - panic(err) - } - fmt.Println("Received:", resp.String()) - } - }() - <- done - fmt.Println("Client done") + done := make(chan bool) + go func() { + for { + resp, err := stream.Recv() + if err == io.EOF { + done <- true + return + } + if err != nil { + panic(err) + } + fmt.Println("Received:", resp.String()) + } + }() + <-done + fmt.Println("Client done") } - diff --git a/15_grpc/streaming/example_01/go.mod b/15_grpc/streaming/example_01/go.mod index 40c0bfb..48004f9 100644 --- a/15_grpc/streaming/example_01/go.mod +++ b/15_grpc/streaming/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/streaming/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/streaming/example_01 go 1.15 diff --git a/15_grpc/streaming/example_01/numbers.proto b/15_grpc/streaming/example_01/numbers.proto index 7900aff..5cb731c 100644 --- a/15_grpc/streaming/example_01/numbers.proto +++ b/15_grpc/streaming/example_01/numbers.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package numbers; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/streaming/example_01/numbers"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/streaming/example_01/numbers"; message NumRequest { int64 from = 1; diff --git a/15_grpc/streaming/example_01/server/server.go b/15_grpc/streaming/example_01/server/server.go index a4b6927..5c39685 100644 --- a/15_grpc/streaming/example_01/server/server.go +++ b/15_grpc/streaming/example_01/server/server.go @@ -1,51 +1,52 @@ package main import ( - "errors" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/streaming/example_01/numbers" - "google.golang.org/grpc" - "math/rand" - "net" - "time" + "errors" + "fmt" + "math/rand" + "net" + "time" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/streaming/example_01/numbers" + "google.golang.org/grpc" ) -type NumServer struct{ - pb.UnimplementedNumServiceServer +type NumServer struct { + pb.UnimplementedNumServiceServer } func (n *NumServer) Rnd(req *pb.NumRequest, stream pb.NumService_RndServer) error { - fmt.Println(req.String()) - if req.N <= 0 { - return errors.New("N must be greater than zero") - } - if req.To <= req.From { - return errors.New("to must be greater or equal than from") - } - done := make(chan bool) - go func() { - for counter:=0;counter 35 { - fmt.Println("Beyond the limit!!!") - done <- true - stream.CloseSend() - return - } - } + for { + stats, err := stream.Recv() + if err != nil { + panic(err) + } + fmt.Println(stats.String()) + if stats.TotalChar > 35 { + fmt.Println("Beyond the limit!!!") + done <- true + stream.CloseSend() + return + } + } } - func main() { - conn, err := grpc.Dial(":50051", grpc.WithInsecure(), grpc.WithBlock()) - if err != nil { - panic(err) - } - defer conn.Close() - - c := pb.NewChatServiceClient(conn) - - stream, err := c.SendTxt(context.Background()) - if err != nil { - panic(err) - } - done := make(chan bool) - go Stats(stream, done) - go Chat(stream, done) - - <- done + conn, err := grpc.Dial(":50051", grpc.WithInsecure(), grpc.WithBlock()) + if err != nil { + panic(err) + } + defer conn.Close() + + c := pb.NewChatServiceClient(conn) + + stream, err := c.SendTxt(context.Background()) + if err != nil { + panic(err) + } + done := make(chan bool) + go Stats(stream, done) + go Chat(stream, done) + + <-done } - diff --git a/15_grpc/streaming/example_03/go.mod b/15_grpc/streaming/example_03/go.mod index 2157c7b..ad3ef33 100644 --- a/15_grpc/streaming/example_03/go.mod +++ b/15_grpc/streaming/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/streaming/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/streaming/example_03 go 1.15 diff --git a/15_grpc/streaming/example_03/server/server.go b/15_grpc/streaming/example_03/server/server.go index f4804f0..67f1523 100644 --- a/15_grpc/streaming/example_03/server/server.go +++ b/15_grpc/streaming/example_03/server/server.go @@ -1,55 +1,56 @@ package main import ( - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/streaming/example_03/chat" - "google.golang.org/grpc" - "io" - "net" - "time" + "fmt" + "io" + "net" + "time" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/streaming/example_03/chat" + "google.golang.org/grpc" ) -type ChatServer struct{ - pb.UnimplementedChatServiceServer +type ChatServer struct { + pb.UnimplementedChatServiceServer } func (c *ChatServer) SendTxt(stream pb.ChatService_SendTxtServer) error { - var total int64 = 0 - go func(){ - for { - t := time.NewTicker(time.Second*2) - select { - case <- t.C: - stream.Send(&pb.StatsResponse{TotalChar: total}) - } - } - }() - for { - next, err := stream.Recv() - if err == io.EOF { - fmt.Println("Client closed") - return nil - } - if err != nil { - return err - } - fmt.Println("->", next.Txt) - total = total + int64(len(next.Txt)) - } - - return nil + var total int64 = 0 + go func() { + for { + t := time.NewTicker(time.Second * 2) + select { + case <-t.C: + stream.Send(&pb.StatsResponse{TotalChar: total}) + } + } + }() + for { + next, err := stream.Recv() + if err == io.EOF { + fmt.Println("Client closed") + return nil + } + if err != nil { + return err + } + fmt.Println("->", next.Txt) + total = total + int64(len(next.Txt)) + } + + return nil } func main() { - lis, err := net.Listen("tcp", "localhost:50051") - if err != nil { - panic(err) - } - s := grpc.NewServer() + lis, err := net.Listen("tcp", "localhost:50051") + if err != nil { + panic(err) + } + s := grpc.NewServer() - pb.RegisterChatServiceServer(s, &ChatServer{}) + pb.RegisterChatServiceServer(s, &ChatServer{}) - if err := s.Serve(lis); err != nil { - panic(err) - } + if err := s.Serve(lis); err != nil { + panic(err) + } } diff --git a/15_grpc/testing/example_01/go.mod b/15_grpc/testing/example_01/go.mod index 72befe1..3ebf9f4 100644 --- a/15_grpc/testing/example_01/go.mod +++ b/15_grpc/testing/example_01/go.mod @@ -1,8 +1,8 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpcurl/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpcurl/example_01 go 1.15 -replace github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01/user => /Users/juan/nalej_workspace/src/github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01/user +replace github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01/user => /Users/juan/nalej_workspace/src/github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01/user require ( google.golang.org/grpc v1.35.0 // indirect diff --git a/15_grpc/testing/example_01/server.go b/15_grpc/testing/example_01/server.go index f9d00f0..9332d6e 100644 --- a/15_grpc/testing/example_01/server.go +++ b/15_grpc/testing/example_01/server.go @@ -1,34 +1,35 @@ package main import ( - "context" - "fmt" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/grpc/example_01/user" - "google.golang.org/grpc" - "google.golang.org/grpc/reflection" - "net" + "context" + "fmt" + "net" + + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/grpc/example_01/user" + "google.golang.org/grpc" + "google.golang.org/grpc/reflection" ) -type UserServer struct{ - pb.UnimplementedUserServiceServer +type UserServer struct { + pb.UnimplementedUserServiceServer } func (u *UserServer) GetUser(ctx context.Context, req *pb.UserRequest) (*pb.User, error) { - fmt.Println("Server received:", req.String()) - return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil + fmt.Println("Server received:", req.String()) + return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil } func main() { - lis, err := net.Listen("tcp", "localhost:50051") - if err != nil { - panic(err) - } - s := grpc.NewServer() - pb.RegisterUserServiceServer(s, &UserServer{}) + lis, err := net.Listen("tcp", "localhost:50051") + if err != nil { + panic(err) + } + s := grpc.NewServer() + pb.RegisterUserServiceServer(s, &UserServer{}) - reflection.Register(s) + reflection.Register(s) - if err := s.Serve(lis); err != nil { - panic(err) - } + if err := s.Serve(lis); err != nil { + panic(err) + } } diff --git a/15_grpc/transcoding/example_01/go.mod b/15_grpc/transcoding/example_01/go.mod index cbff55d..cab499b 100644 --- a/15_grpc/transcoding/example_01/go.mod +++ b/15_grpc/transcoding/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/transcoding/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/transcoding/example_01 go 1.15 diff --git a/15_grpc/transcoding/example_01/server.go b/15_grpc/transcoding/example_01/server.go index 8d107b3..c98eb1e 100644 --- a/15_grpc/transcoding/example_01/server.go +++ b/15_grpc/transcoding/example_01/server.go @@ -1,70 +1,70 @@ package main import ( - "context" - "fmt" - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - pb "github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/transcoding/example_01/user" - "google.golang.org/grpc" - "net" - "net/http" + "context" + "fmt" + "net" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + pb "github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/transcoding/example_01/user" + "google.golang.org/grpc" ) -type UserServer struct{ - httpAddr string - grpcAddr string - pb.UnimplementedUserServiceServer +type UserServer struct { + httpAddr string + grpcAddr string + pb.UnimplementedUserServiceServer } func (u *UserServer) Get(ctx context.Context, req *pb.UserRequest) (*pb.User, error) { - fmt.Println("Server received:", req.String()) - return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil + fmt.Println("Server received:", req.String()) + return &pb.User{UserId: "John", Email: "john@gmail.com"}, nil } func (u *UserServer) Create(ctx context.Context, req *pb.User) (*pb.User, error) { - fmt.Println("Server received:", req.String()) - return &pb.User{UserId: req.UserId, Email: req.Email}, nil + fmt.Println("Server received:", req.String()) + return &pb.User{UserId: req.UserId, Email: req.Email}, nil } func (u *UserServer) ServeGrpc() { - lis, err := net.Listen("tcp", u.grpcAddr) - if err != nil { - panic(err) - } - s := grpc.NewServer() - pb.RegisterUserServiceServer(s, u) - fmt.Println("Server listening GRCP:") + lis, err := net.Listen("tcp", u.grpcAddr) + if err != nil { + panic(err) + } + s := grpc.NewServer() + pb.RegisterUserServiceServer(s, u) + fmt.Println("Server listening GRCP:") - if err := s.Serve(lis); err != nil { - panic(err) - } + if err := s.Serve(lis); err != nil { + panic(err) + } } func (u *UserServer) ServeHttp() { - mux := runtime.NewServeMux() - opts := []grpc.DialOption{grpc.WithInsecure()} - endpoint := u.grpcAddr + mux := runtime.NewServeMux() + opts := []grpc.DialOption{grpc.WithInsecure()} + endpoint := u.grpcAddr - err := pb.RegisterUserServiceHandlerFromEndpoint(context.Background(), mux, endpoint, opts) - if err != nil { - panic(err) - } + err := pb.RegisterUserServiceHandlerFromEndpoint(context.Background(), mux, endpoint, opts) + if err != nil { + panic(err) + } - httpServer := &http.Server{ - Addr: u.httpAddr, - Handler: mux, - } + httpServer := &http.Server{ + Addr: u.httpAddr, + Handler: mux, + } - fmt.Println("Server listing HTTP:") - if err = httpServer.ListenAndServe(); err!=nil{ - panic(err) - } + fmt.Println("Server listing HTTP:") + if err = httpServer.ListenAndServe(); err != nil { + panic(err) + } } - func main() { - us := UserServer{httpAddr:":8080",grpcAddr:":50051"} - go us.ServeGrpc() - us.ServeHttp() + us := UserServer{httpAddr: ":8080", grpcAddr: ":50051"} + go us.ServeGrpc() + us.ServeHttp() } diff --git a/15_grpc/transcoding/example_01/user.proto b/15_grpc/transcoding/example_01/user.proto index 15126f2..dd842b3 100644 --- a/15_grpc/transcoding/example_01/user.proto +++ b/15_grpc/transcoding/example_01/user.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package user; -option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/13_grpc/transcoding/example_01/user"; +option go_package="github.com/juanmanuel-tirado/savetheworldwithgo/15_grpc/transcoding/example_01/user"; import "google/api/annotations.proto"; diff --git a/16_logger/zerolog/advanced/example_01/go.mod b/16_logger/zerolog/advanced/example_01/go.mod index 95d9252..114ea32 100644 --- a/16_logger/zerolog/advanced/example_01/go.mod +++ b/16_logger/zerolog/advanced/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/advanced/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/advanced/example_01 go 1.15 diff --git a/16_logger/zerolog/advanced/example_02/go.mod b/16_logger/zerolog/advanced/example_02/go.mod index a222a94..6d5467e 100644 --- a/16_logger/zerolog/advanced/example_02/go.mod +++ b/16_logger/zerolog/advanced/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/advanced/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/advanced/example_02 go 1.15 diff --git a/16_logger/zerolog/advanced/example_03/go.mod b/16_logger/zerolog/advanced/example_03/go.mod index 0cd9728..142d7bf 100644 --- a/16_logger/zerolog/advanced/example_03/go.mod +++ b/16_logger/zerolog/advanced/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/advanced/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/advanced/example_03 go 1.15 diff --git a/16_logger/zerolog/advanced/example_04/go.mod b/16_logger/zerolog/advanced/example_04/go.mod index f3f2497..f5969b6 100644 --- a/16_logger/zerolog/advanced/example_04/go.mod +++ b/16_logger/zerolog/advanced/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/advanced/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/advanced/example_04 go 1.15 diff --git a/16_logger/zerolog/advanced/example_05/go.mod b/16_logger/zerolog/advanced/example_05/go.mod index 0d686fb..56787c7 100644 --- a/16_logger/zerolog/advanced/example_05/go.mod +++ b/16_logger/zerolog/advanced/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/advanced/example_05 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/advanced/example_05 go 1.15 diff --git a/16_logger/zerolog/basics/example_01/go.mod b/16_logger/zerolog/basics/example_01/go.mod index ac9d557..e9a93bb 100644 --- a/16_logger/zerolog/basics/example_01/go.mod +++ b/16_logger/zerolog/basics/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/example_01 go 1.15 diff --git a/16_logger/zerolog/basics/example_02/go.mod b/16_logger/zerolog/basics/example_02/go.mod index 6243ce6..de4bf49 100644 --- a/16_logger/zerolog/basics/example_02/go.mod +++ b/16_logger/zerolog/basics/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/example_02 go 1.15 diff --git a/16_logger/zerolog/basics/example_03/go.mod b/16_logger/zerolog/basics/example_03/go.mod index 4f7f01b..849646d 100644 --- a/16_logger/zerolog/basics/example_03/go.mod +++ b/16_logger/zerolog/basics/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/example_03 go 1.15 diff --git a/16_logger/zerolog/basics/example_04/go.mod b/16_logger/zerolog/basics/example_04/go.mod index 37466b9..3a59f21 100644 --- a/16_logger/zerolog/basics/example_04/go.mod +++ b/16_logger/zerolog/basics/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/example_04 go 1.15 diff --git a/16_logger/zerolog/basics/example_05/go.mod b/16_logger/zerolog/basics/example_05/go.mod index 256c81d..9151a97 100644 --- a/16_logger/zerolog/basics/example_05/go.mod +++ b/16_logger/zerolog/basics/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/basics/example_05 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/basics/example_05 go 1.15 diff --git a/16_logger/zerolog/basics/example_06/go.mod b/16_logger/zerolog/basics/example_06/go.mod index 58791f0..eb47f89 100644 --- a/16_logger/zerolog/basics/example_06/go.mod +++ b/16_logger/zerolog/basics/example_06/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/basics/example_06 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/basics/example_06 go 1.15 diff --git a/16_logger/zerolog/settings/example_01/go.mod b/16_logger/zerolog/settings/example_01/go.mod index c8eb863..a13b2d8 100644 --- a/16_logger/zerolog/settings/example_01/go.mod +++ b/16_logger/zerolog/settings/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/settings/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/settings/example_01 go 1.15 diff --git a/16_logger/zerolog/settings/example_02/go.mod b/16_logger/zerolog/settings/example_02/go.mod index fb2682a..b5d09ab 100644 --- a/16_logger/zerolog/settings/example_02/go.mod +++ b/16_logger/zerolog/settings/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/settings/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/settings/example_02 go 1.15 diff --git a/16_logger/zerolog/settings/example_03/go.mod b/16_logger/zerolog/settings/example_03/go.mod index 70fa8ba..b04d1fe 100644 --- a/16_logger/zerolog/settings/example_03/go.mod +++ b/16_logger/zerolog/settings/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/settings/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/settings/example_03 go 1.15 diff --git a/16_logger/zerolog/settings/example_04/go.mod b/16_logger/zerolog/settings/example_04/go.mod index 045956c..27bf6b1 100644 --- a/16_logger/zerolog/settings/example_04/go.mod +++ b/16_logger/zerolog/settings/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/14_logger/zerolog/settings/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/16_logger/zerolog/settings/example_04 go 1.15 diff --git a/17_cli/cobra/advanced/example_01/go.mod b/17_cli/cobra/advanced/example_01/go.mod index c2295c6..da7e540 100644 --- a/17_cli/cobra/advanced/example_01/go.mod +++ b/17_cli/cobra/advanced/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_01 go 1.15 diff --git a/17_cli/cobra/advanced/example_02/go.mod b/17_cli/cobra/advanced/example_02/go.mod index 9f0b712..c3364e2 100644 --- a/17_cli/cobra/advanced/example_02/go.mod +++ b/17_cli/cobra/advanced/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_02 go 1.15 diff --git a/17_cli/cobra/advanced/example_03/go.mod b/17_cli/cobra/advanced/example_03/go.mod index 6cb92f1..4873dea 100644 --- a/17_cli/cobra/advanced/example_03/go.mod +++ b/17_cli/cobra/advanced/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_03 go 1.15 diff --git a/17_cli/cobra/advanced/example_03/main.go b/17_cli/cobra/advanced/example_03/main.go index 974dff4..09dadc8 100644 --- a/17_cli/cobra/advanced/example_03/main.go +++ b/17_cli/cobra/advanced/example_03/main.go @@ -15,7 +15,7 @@ limitations under the License. */ package main -import "github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_03/cmd" +import "github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_03/cmd" func main() { cmd.Execute() diff --git a/17_cli/cobra/advanced/example_04/go.mod b/17_cli/cobra/advanced/example_04/go.mod index a6c909c..b48a548 100644 --- a/17_cli/cobra/advanced/example_04/go.mod +++ b/17_cli/cobra/advanced/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_04 go 1.15 diff --git a/17_cli/cobra/advanced/example_05/db.go b/17_cli/cobra/advanced/example_05/db.go index fe70233..7616d19 100644 --- a/17_cli/cobra/advanced/example_05/db.go +++ b/17_cli/cobra/advanced/example_05/db.go @@ -2,31 +2,32 @@ package main import ( "fmt" - "github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_05/cmd" - "github.com/spf13/cobra" - "os" "math/rand" + "os" "time" + + "github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_05/cmd" + "github.com/spf13/cobra" ) var RootCmd = &cobra.Command{ - Use: "db", + Use: "db", Long: "Root command", } var GetCmd = &cobra.Command{ - Use: "get", + Use: "get", Short: "Get user data", - Args: cobra.ExactValidArgs(1), + Args: cobra.ExactValidArgs(1), Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("Get user %s!!!\n",args[0]) + fmt.Printf("Get user %s!!!\n", args[0]) }, ValidArgsFunction: UserGet, } -func UserGet (cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { +func UserGet(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { rand.Seed(time.Now().UnixNano()) - if rand.Int() % 2 == 0 { + if rand.Int()%2 == 0 { return []string{"John", "Mary"}, cobra.ShellCompDirectiveNoFileComp } return []string{"Ernest", "Rick", "Mary"}, cobra.ShellCompDirectiveNoFileComp diff --git a/17_cli/cobra/advanced/example_05/go.mod b/17_cli/cobra/advanced/example_05/go.mod index bde7623..302f6b8 100644 --- a/17_cli/cobra/advanced/example_05/go.mod +++ b/17_cli/cobra/advanced/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/advanced/example_05 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/advanced/example_05 go 1.15 diff --git a/17_cli/cobra/basics/example_01/go.mod b/17_cli/cobra/basics/example_01/go.mod index 5273ee6..a82c7df 100644 --- a/17_cli/cobra/basics/example_01/go.mod +++ b/17_cli/cobra/basics/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/basics/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/basics/example_01 go 1.15 diff --git a/17_cli/cobra/commands/example_01/go.mod b/17_cli/cobra/commands/example_01/go.mod index 3960fa0..1a60253 100644 --- a/17_cli/cobra/commands/example_01/go.mod +++ b/17_cli/cobra/commands/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/example_01 go 1.15 diff --git a/17_cli/cobra/commands/example_02/go.mod b/17_cli/cobra/commands/example_02/go.mod index 983f393..b5b7c49 100644 --- a/17_cli/cobra/commands/example_02/go.mod +++ b/17_cli/cobra/commands/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/commands/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/commands/example_02 go 1.15 diff --git a/17_cli/cobra/commands/example_03/go.mod b/17_cli/cobra/commands/example_03/go.mod index 3d81c80..a086a92 100644 --- a/17_cli/cobra/commands/example_03/go.mod +++ b/17_cli/cobra/commands/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/commands/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/commands/example_03 go 1.15 diff --git a/17_cli/cobra/flags/example_01/go.mod b/17_cli/cobra/flags/example_01/go.mod index 87d9e7b..53c28d0 100644 --- a/17_cli/cobra/flags/example_01/go.mod +++ b/17_cli/cobra/flags/example_01/go.mod @@ -1,3 +1,3 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/flags/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/flags/example_01 go 1.15 diff --git a/17_cli/cobra/flags/example_02/go.mod b/17_cli/cobra/flags/example_02/go.mod index 62ac0a9..62cc3f9 100644 --- a/17_cli/cobra/flags/example_02/go.mod +++ b/17_cli/cobra/flags/example_02/go.mod @@ -1,3 +1,3 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/flags/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/flags/example_02 go 1.15 diff --git a/17_cli/cobra/flags/example_03/go.mod b/17_cli/cobra/flags/example_03/go.mod index 42cf064..b2686c0 100644 --- a/17_cli/cobra/flags/example_03/go.mod +++ b/17_cli/cobra/flags/example_03/go.mod @@ -1,3 +1,3 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/flags/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/flags/example_03 go 1.15 diff --git a/17_cli/cobra/flags/example_04/go.mod b/17_cli/cobra/flags/example_04/go.mod index 3960fa0..1a60253 100644 --- a/17_cli/cobra/flags/example_04/go.mod +++ b/17_cli/cobra/flags/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/example_01 go 1.15 diff --git a/17_cli/cobra/flags/example_05/go.mod b/17_cli/cobra/flags/example_05/go.mod index 3960fa0..1a60253 100644 --- a/17_cli/cobra/flags/example_05/go.mod +++ b/17_cli/cobra/flags/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/15_cli/cobra/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/17_cli/cobra/example_01 go 1.15 diff --git a/18_sql/gorm/example_01/go.mod b/18_sql/gorm/example_01/go.mod index 601718f..fc190f5 100644 --- a/18_sql/gorm/example_01/go.mod +++ b/18_sql/gorm/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/example_01 go 1.15 diff --git a/18_sql/gorm/manipulate/example_01/go.mod b/18_sql/gorm/manipulate/example_01/go.mod index 0b9d439..fa84791 100644 --- a/18_sql/gorm/manipulate/example_01/go.mod +++ b/18_sql/gorm/manipulate/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/manipulate/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/manipulate/example_01 go 1.15 diff --git a/18_sql/gorm/manipulate/example_02/go.mod b/18_sql/gorm/manipulate/example_02/go.mod index cbf213e..c90a7d2 100644 --- a/18_sql/gorm/manipulate/example_02/go.mod +++ b/18_sql/gorm/manipulate/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/manipulate/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/manipulate/example_02 go 1.15 diff --git a/18_sql/gorm/manipulate/example_03/go.mod b/18_sql/gorm/manipulate/example_03/go.mod index ffc01db..d4f6f9d 100644 --- a/18_sql/gorm/manipulate/example_03/go.mod +++ b/18_sql/gorm/manipulate/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/manipulate/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/manipulate/example_03 go 1.15 diff --git a/18_sql/gorm/manipulate/example_04/go.mod b/18_sql/gorm/manipulate/example_04/go.mod index 2a20dff..60c088c 100644 --- a/18_sql/gorm/manipulate/example_04/go.mod +++ b/18_sql/gorm/manipulate/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/manipulate/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/manipulate/example_04 go 1.15 diff --git a/18_sql/gorm/modelling/example_01/go.mod b/18_sql/gorm/modelling/example_01/go.mod index 844efd1..ecd33d8 100644 --- a/18_sql/gorm/modelling/example_01/go.mod +++ b/18_sql/gorm/modelling/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/example_02 go 1.15 diff --git a/18_sql/gorm/modelling/example_02/go.mod b/18_sql/gorm/modelling/example_02/go.mod index bedba90..ff60c8d 100644 --- a/18_sql/gorm/modelling/example_02/go.mod +++ b/18_sql/gorm/modelling/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/example_03 go 1.15 diff --git a/18_sql/gorm/modelling/example_03/go.mod b/18_sql/gorm/modelling/example_03/go.mod index 6c2b7cd..b984a16 100644 --- a/18_sql/gorm/modelling/example_03/go.mod +++ b/18_sql/gorm/modelling/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/example_04 go 1.15 diff --git a/18_sql/gorm/modelling/example_04/go.mod b/18_sql/gorm/modelling/example_04/go.mod index b9c1e7f..4c0e102 100644 --- a/18_sql/gorm/modelling/example_04/go.mod +++ b/18_sql/gorm/modelling/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/example_05 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/example_05 go 1.15 diff --git a/18_sql/gorm/modelling/example_05/go.mod b/18_sql/gorm/modelling/example_05/go.mod index fef9ff7..479e725 100644 --- a/18_sql/gorm/modelling/example_05/go.mod +++ b/18_sql/gorm/modelling/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/example_06 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/example_06 go 1.15 diff --git a/18_sql/gorm/transactions/example_01/go.mod b/18_sql/gorm/transactions/example_01/go.mod index a2682d2..c8a093d 100644 --- a/18_sql/gorm/transactions/example_01/go.mod +++ b/18_sql/gorm/transactions/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/transactions/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/transactions/example_01 go 1.15 diff --git a/18_sql/gorm/transactions/example_02/go.mod b/18_sql/gorm/transactions/example_02/go.mod index 4744c01..783965f 100644 --- a/18_sql/gorm/transactions/example_02/go.mod +++ b/18_sql/gorm/transactions/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/gorm/transactions/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/gorm/transactions/example_02 go 1.15 diff --git a/18_sql/sql/example_01/go.mod b/18_sql/sql/example_01/go.mod index 0533068..362ad58 100644 --- a/18_sql/sql/example_01/go.mod +++ b/18_sql/sql/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/example_01 go 1.15 diff --git a/18_sql/sql/example_02/go.mod b/18_sql/sql/example_02/go.mod index c02954c..e43570c 100644 --- a/18_sql/sql/example_02/go.mod +++ b/18_sql/sql/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/example_02 go 1.15 diff --git a/18_sql/sql/example_03/go.mod b/18_sql/sql/example_03/go.mod index aaeb167..da394a1 100644 --- a/18_sql/sql/example_03/go.mod +++ b/18_sql/sql/example_03/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/example_03 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/example_03 go 1.15 diff --git a/18_sql/sql/example_04/go.mod b/18_sql/sql/example_04/go.mod index 06ceb1c..cc9e1c3 100644 --- a/18_sql/sql/example_04/go.mod +++ b/18_sql/sql/example_04/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/example_04 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/example_04 go 1.15 diff --git a/18_sql/sql/example_05/go.mod b/18_sql/sql/example_05/go.mod index 128356d..34f7e33 100644 --- a/18_sql/sql/example_05/go.mod +++ b/18_sql/sql/example_05/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/16_sql/sql/example_05 +module github.com/juanmanuel-tirado/savetheworldwithgo/18_sql/sql/example_05 go 1.15 diff --git a/19_nosql/gocql/connection/example_01/go.mod b/19_nosql/gocql/connection/example_01/go.mod index 7f2b929..beb2c18 100644 --- a/19_nosql/gocql/connection/example_01/go.mod +++ b/19_nosql/gocql/connection/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/17_nosql/gocql/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/19_nosql/gocql/example_01 go 1.15 diff --git a/19_nosql/gocql/manipulate/example_01/go.mod b/19_nosql/gocql/manipulate/example_01/go.mod index 63dba22..805553f 100644 --- a/19_nosql/gocql/manipulate/example_01/go.mod +++ b/19_nosql/gocql/manipulate/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/17_nosql/gocql/manipulate/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/19_nosql/gocql/manipulate/example_01 go 1.15 diff --git a/19_nosql/gocql/manipulate/example_02/go.mod b/19_nosql/gocql/manipulate/example_02/go.mod index 48687d7..366e2f7 100644 --- a/19_nosql/gocql/manipulate/example_02/go.mod +++ b/19_nosql/gocql/manipulate/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/17_nosql/gocql/manipulate/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/19_nosql/gocql/manipulate/example_02 go 1.15 diff --git a/19_nosql/gocql/queries/example_01/go.mod b/19_nosql/gocql/queries/example_01/go.mod index 01fe4a5..b78ffcd 100644 --- a/19_nosql/gocql/queries/example_01/go.mod +++ b/19_nosql/gocql/queries/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/17_nosql/gocql/queries/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/19_nosql/gocql/queries/example_01 go 1.15 diff --git a/19_nosql/gocql/queries/example_02/go.mod b/19_nosql/gocql/queries/example_02/go.mod index 4bcfe2e..bf6ce98 100644 --- a/19_nosql/gocql/queries/example_02/go.mod +++ b/19_nosql/gocql/queries/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/17_nosql/gocql/queries/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/19_nosql/gocql/queries/example_02 go 1.15 diff --git a/19_nosql/gocql/udts/example_01/go.mod b/19_nosql/gocql/udts/example_01/go.mod index 7af257e..8d0f78e 100644 --- a/19_nosql/gocql/udts/example_01/go.mod +++ b/19_nosql/gocql/udts/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/17_nosql/gocql/udts/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/19_nosql/gocql/udts/example_01 go 1.15 diff --git a/20_kafka/confluent/example_01/go.mod b/20_kafka/confluent/example_01/go.mod index 42e072f..f3176dd 100644 --- a/20_kafka/confluent/example_01/go.mod +++ b/20_kafka/confluent/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/18_kafka/confluent/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/20_kafka/confluent/example_01 go 1.15 diff --git a/20_kafka/confluent/example_02/go.mod b/20_kafka/confluent/example_02/go.mod index 1e933e2..25ce444 100644 --- a/20_kafka/confluent/example_02/go.mod +++ b/20_kafka/confluent/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/18_kafka/confluent/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/20_kafka/confluent/example_02 go 1.15 diff --git a/20_kafka/rest/example_01/go.mod b/20_kafka/rest/example_01/go.mod index 977c0ee..99d79d5 100644 --- a/20_kafka/rest/example_01/go.mod +++ b/20_kafka/rest/example_01/go.mod @@ -1,3 +1,3 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/18_kafka/rest/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/20_kafka/rest/example_01 go 1.15 diff --git a/20_kafka/segmentio/example_01/go.mod b/20_kafka/segmentio/example_01/go.mod index c66f500..b901386 100644 --- a/20_kafka/segmentio/example_01/go.mod +++ b/20_kafka/segmentio/example_01/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/18_kafka/kafka-go/example_01 +module github.com/juanmanuel-tirado/savetheworldwithgo/20_kafka/kafka-go/example_01 go 1.15 diff --git a/20_kafka/segmentio/example_02/go.mod b/20_kafka/segmentio/example_02/go.mod index fe2aeda..3ce0788 100644 --- a/20_kafka/segmentio/example_02/go.mod +++ b/20_kafka/segmentio/example_02/go.mod @@ -1,4 +1,4 @@ -module github.com/juanmanuel-tirado/savetheworldwithgo/18_kafka/kafka-go/example_02 +module github.com/juanmanuel-tirado/savetheworldwithgo/20_kafka/kafka-go/example_02 go 1.15