-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the imports after the chapter changes
The chapter changes didn't update the code to point to the right folders. The code here just does that using sed. - protobuffers 12 -> 14 - grpc 13 -> 15 - logger 14 -> 16 - cli 15 -> 17 - sql 16 -> 18 - nosql 17 -> 19 - kafka 18 -> 20
- Loading branch information
1 parent
c084643
commit f5ae360
Showing
114 changed files
with
667 additions
and
668 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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:"[email protected]", UserId: "John"} | ||
u := user.User{Email: "[email protected]", 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()) | ||
} | ||
|
||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "[email protected]"} | ||
userB := user.User{UserId: "Mary", Email:"[email protected]"} | ||
userA := user.User{UserId: "John", Email: "[email protected]"} | ||
userB := user.User{UserId: "Mary", Email: "[email protected]"} | ||
|
||
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()) | ||
} | ||
|
||
|
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "[email protected]"} | ||
userB := user.User{UserId: "Mary", Email:"[email protected]"} | ||
userA := user.User{UserId: "John", Email: "[email protected]"} | ||
userB := user.User{UserId: "Mary", Email: "[email protected]"} | ||
|
||
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()) | ||
} | ||
|
||
|
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "[email protected]"} | ||
userB := group.Group_User{UserId: "Mary", Email:"[email protected]"} | ||
userA := group.Group_User{UserId: "John", Email: "[email protected]"} | ||
userB := group.Group_User{UserId: "Mary", Email: "[email protected]"} | ||
|
||
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()) | ||
} | ||
|
||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: "[email protected]", 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: "[email protected]", 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()) | ||
} | ||
|
||
|
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
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
Oops, something went wrong.