Skip to content
This repository was archived by the owner on Jul 4, 2024. It is now read-only.

Commit 01cfe09

Browse files
committed
fix: update git repo references and update protocomments
1 parent 8e7298b commit 01cfe09

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

cmd/new/new.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import (
88
"strings"
99
"text/template"
1010

11+
"github.com/pkg/errors"
12+
"github.com/urfave/cli/v2"
13+
1114
mcli "github.com/go-micro/cli/cmd"
1215
"github.com/go-micro/cli/generator"
1316
tmpl "github.com/go-micro/cli/generator/template"
14-
"github.com/pkg/errors"
15-
"github.com/urfave/cli/v2"
1617
)
1718

1819
var flags []cli.Flag = []cli.Flag{
@@ -286,20 +287,17 @@ func clientComments(name, dir string) []string {
286287

287288
func protoComments(name, dir string, sqlc bool) ([]string, error) {
288289
tmp := `
289-
download protoc zip packages (protoc-$VERSION-$PLATFORM.zip) and install:
290-
291-
visit https://github.com/protocolbuffers/protobuf/releases/latest
292-
293-
download protobuf for go-micro:
290+
install requirements:
294291
295-
go get -u google.golang.org/protobuf/proto
296-
go install github.com/golang/protobuf/protoc-gen-go@latest
297-
go install go-micro.dev/v4/cmd/protoc-gen-micro@v4
292+
protoc is needed for code generation. You can either install it using your
293+
pacakge manager, or manually install it by downloading the protoc zip packages
294+
(protoc-$VERSION-$PLATFORM.zip) from https://github.com/protocolbuffers/protobuf/releases/latest
295+
and installing its contents.
298296
299297
compile the proto file {{ .Name }}.proto and install dependencies:
300298
301299
cd {{ .Dir }}
302-
make proto {{ if .Sqlc }}sqlc {{ end }}update tidy`
300+
make proto init {{ if .Sqlc }}sqlc {{ end }}update tidy`
303301

304302
t, err := template.New("comments").Parse(tmp)
305303
if err != nil {

generator/template/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ func main() {
147147
ctx, cancel := context.WithCancel(context.Background())
148148
{{- end }}
149149
150+
{{- if .ID}}
151+
// Use Kubernetes hostname as id
152+
node := uuid.New().String()
153+
if host, ok := os.LookupEnv("HOSTNAME"); ok {
154+
node = host
155+
}
156+
{{- end}}
157+
150158
{{end}} // Create service
151159
srv := micro.NewService(
152160
{{- if .GRPC}}

generator/template/makefile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ var Makefile = `GOPATH:=$(shell go env GOPATH)
66
.PHONY: init
77
init:
88
@go get -u google.golang.org/protobuf/proto
9-
@go install github.com/golang/protobuf/protoc-gen-go@latest
10-
@go install go-micro.dev/v4/cmd/protoc-gen-micro@v4
9+
@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
10+
@go install github.com/go-micro/generator/cmd/protoc-gen-micro@latest
1111
{{- if .Tern}}
1212
@go install github.com/kyleconroy/sqlc/cmd/sqlc@latest
1313
{{- end}}

0 commit comments

Comments
 (0)