forked from kujtimiihoxha/kit
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from bootun/win_support
support windows
- Loading branch information
Showing
4 changed files
with
105 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,13 @@ import ( | |
"github.com/spf13/viper" | ||
) | ||
|
||
const version = "v1.1.2" | ||
|
||
// RootCmd is the root command of kit | ||
var RootCmd = &cobra.Command{ | ||
Use: "kit", | ||
Short: "Go-Kit CLI", | ||
Use: "kit", | ||
Short: "Go-Kit CLI", | ||
Version: version, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
|
@@ -46,8 +49,8 @@ func checkProtoc() bool { | |
`Install proto3. | ||
https://github.com/google/protobuf/releases | ||
Update protoc Go bindings via | ||
> go get -u github.com/golang/protobuf/proto | ||
> go get -u github.com/golang/protobuf/protoc-gen-go | ||
> go install google.golang.org/protobuf/cmd/[email protected] | ||
> go install google.golang.org/grpc/cmd/protoc-gen-go[email protected] | ||
See also | ||
https://github.com/grpc/grpc-go/tree/master/examples`, | ||
|
@@ -60,7 +63,8 @@ https://github.com/grpc/grpc-go/tree/master/examples`, | |
> ./autogen.sh ; ./configure ; make ; make install | ||
Update protoc Go bindings via | ||
> go get -u github.com/golang/protobuf/{proto,protoc-gen-go} | ||
> go install google.golang.org/protobuf/cmd/[email protected] | ||
> go install google.golang.org/grpc/cmd/[email protected] | ||
See also | ||
https://github.com/grpc/grpc-go/tree/master/examples`, | ||
|
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package grpc | ||
|
||
import "fmt" | ||
|
||
const ( | ||
scriptTemplate = `#!/usr/bin/env sh | ||
# Install proto3 | ||
# sudo apt-get install -y git autoconf automake libtool curl make g++ unzip | ||
# git clone https://github.com/google/protobuf.git | ||
# cd protobuf/ | ||
# ./autogen.sh | ||
# ./configure | ||
# make | ||
# make check | ||
# sudo make install | ||
# sudo ldconfig # refresh shared library cache. | ||
# | ||
# Update protoc Go bindings via | ||
# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
# | ||
# See also | ||
# https://github.com/grpc/grpc-go/tree/master/examples | ||
protoc --go_out=. --go_opt=paths=source_relative \ | ||
--go-grpc_out=. --go-grpc_opt=paths=source_relative %s` | ||
|
||
windowsScriptTemplate = `:: Install proto3. | ||
:: https://github.com/google/protobuf/releases | ||
:: Update protoc Go bindings via | ||
:: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
:: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
:: | ||
:: See also | ||
:: https://github.com/grpc/grpc-go/tree/master/examples | ||
protoc --go_out=. --go_opt=paths=source_relative \ | ||
--go-grpc_out=. --go-grpc_opt=paths=source_relative %s` | ||
|
||
darwinScriptText = `#!/usr/bin/env sh | ||
# Install proto3 from source macOS only. | ||
# brew install autoconf automake libtool | ||
# git clone https://github.com/google/protobuf | ||
# ./autogen.sh ; ./configure ; make ; make install | ||
# | ||
# Update protoc Go bindings via | ||
# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | ||
# See also | ||
# https://github.com/grpc/grpc-go/tree/master/examples | ||
protoc --go_out=. --go_opt=paths=source_relative \ | ||
--go-grpc_out=. --go-grpc_opt=paths=source_relative %s` | ||
) | ||
|
||
// WindowsScriptText return gRPC compile script text for windows, | ||
// it uses the syntax of windows batch | ||
func WindowsScriptText(name string) string { | ||
return fmt.Sprintf(windowsScriptTemplate, name) | ||
} | ||
|
||
// DarwinScriptText return gRPC compile script text for macOS, it | ||
// uses the syntax of shell script | ||
func DarwinScriptText(name string) string { | ||
return fmt.Sprintf(darwinScriptText, name) | ||
} | ||
|
||
// ScriptText return gRPC compile script text, it uses the syntax | ||
// of shell script | ||
func ScriptText(name string) string { | ||
return fmt.Sprintf(scriptTemplate, name) | ||
} |