Skip to content

Commit

Permalink
Update the imports after the chapter changes
Browse files Browse the repository at this point in the history
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
SimonRichardson committed Mar 4, 2022
1 parent c084643 commit f5ae360
Show file tree
Hide file tree
Showing 114 changed files with 667 additions and 668 deletions.
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_01/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
33 changes: 16 additions & 17 deletions 14_protocolbuffers/pb/example_01/main.go
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())
}


2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_01/user.proto
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_02/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
39 changes: 19 additions & 20 deletions 14_protocolbuffers/pb/example_02/main.go
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())
}


2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_02/user.proto
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_03/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_03/group.proto
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_03/group/group.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 20 additions & 21 deletions 14_protocolbuffers/pb/example_03/main.go
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())
}


2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_03/user.proto
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_04/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_04/group.proto
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
40 changes: 20 additions & 20 deletions 14_protocolbuffers/pb/example_04/main.go
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())
}


2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_05/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
33 changes: 16 additions & 17 deletions 14_protocolbuffers/pb/example_05/main.go
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())
}


2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_05/user.proto
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
2 changes: 1 addition & 1 deletion 14_protocolbuffers/pb/example_06/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading

0 comments on commit f5ae360

Please sign in to comment.