Skip to content

Commit

Permalink
add .golangci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Sep 1, 2023
1 parent 0c16538 commit 93a6c73
Show file tree
Hide file tree
Showing 49 changed files with 112 additions and 75 deletions.
37 changes: 37 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
run:
timeout: 1m
linters:
enable-all: true
disable:
# deprecated
- nosnakecase
- structcheck
- interfacer
- deadcode
- exhaustivestruct
- maligned
- ifshort
- varcheck
- golint
- scopelint
# not relevant
- varnamelen
linters-settings:
lll:
line-length: 160
gci:
sections:
- Standard
- Default
- Prefix(github.com/bavix)
depguard:
rules:
main:
allow:
- $gostd
- github.com
issues:
exclude-rules:
- path: (.+)_test.go
linters:
- dupl
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ RUN apk -U --no-cache add bash git protobuf &&\
apk del git &&\
apk -v cache clean

COPY . /go/src/github.com/tokopedia/gripmock
COPY . /go/src/github.com/bavix/gripmock

# create necessary dirs and export fix_gopackage.sh
RUN mkdir /proto /stubs &&\
ln -s /go/src/github.com/tokopedia/gripmock/fix_gopackage.sh /bin/
ln -s /go/src/github.com/bavix/gripmock/fix_gopackage.sh /bin/

RUN cd /go/src/github.com/tokopedia/gripmock/protoc-gen-gripmock &&\
RUN cd /go/src/github.com/bavix/gripmock/protoc-gen-gripmock &&\
go install -v &&\
cd /go/src/github.com/tokopedia/gripmock/example/simple/client &&\
cd /go/src/github.com/bavix/gripmock/example/simple/client &&\
go get -u all &&\
cd /go/src/github.com/tokopedia/gripmock &&\
cd /go/src/github.com/bavix/gripmock &&\
go install -v

WORKDIR /go/src/github.com/tokopedia/gripmock
WORKDIR /go/src/github.com/bavix/gripmock

EXPOSE 4770 4771

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019 PT Tokopedia
Copyright 2019 PT bavix

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ The server implementation is in GoLang but the client can be any programming lan
---

### Announcement:
The latest [version (v1.10)](https://github.com/tokopedia/gripmock/releases/tag/v1.10) of gripmock is requiring `go_package` declaration in the `.proto` file. This is due to the latest update of `protoc` plugin that being used by gripmock is making the `go_package` declaration mandatory.
The latest [version (v1.10)](https://github.com/bavix/gripmock/releases/tag/v1.10) of gripmock is requiring `go_package` declaration in the `.proto` file. This is due to the latest update of `protoc` plugin that being used by gripmock is making the `go_package` declaration mandatory.

**Update Feb 2022:**

[Version 1.11-beta](https://github.com/tokopedia/gripmock/releases/tag/v1.11-beta) release is available.
[Version 1.11-beta](https://github.com/bavix/gripmock/releases/tag/v1.11-beta) release is available.
It supports **NO** declaration of `go_package`, please download and test before it can be tagged as stable.

you can get the docker image using `docker pull tkpd/gripmock:v1.11-beta`.
Expand All @@ -28,7 +28,7 @@ basic syntax to run GripMock is
- On a separate terminal we are gonna add a stub into the stub service. Run `curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/add `
- Now we are ready to test it with our client. You can find a client example file under `example/simple/client/`. Execute one of your preferred language. Example for go: `go run example/simple/client/*.go`

Check [`example`](https://github.com/tokopedia/gripmock/tree/master/example) folder for various usecase of gripmock.
Check [`example`](https://github.com/bavix/gripmock/tree/master/example) folder for various usecase of gripmock.

---

Expand Down
6 changes: 3 additions & 3 deletions example/multi-files/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

pb "github.com/tokopedia/gripmock/protogen/example/multi-files"
pb "github.com/bavix/gripmock/protogen/example/multi-files"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand All @@ -24,7 +24,7 @@ func main() {
c := pb.NewGripmock1Client(conn)

// Contact the server and print out its response.
r, err := c.SayHello(context.Background(), &pb.Request1{Name: "tokopedia"})
r, err := c.SayHello(context.Background(), &pb.Request1{Name: "bavix"})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
Expand All @@ -33,7 +33,7 @@ func main() {
c2 := pb.NewGripmock2Client(conn)

// Contact the server and print out its response.
r2, err := c2.SayHello(context.Background(), &pb.Request2{Name: "tokopedia"})
r2, err := c2.SayHello(context.Background(), &pb.Request2{Name: "bavix"})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion example/multi-files/file1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package multifiles;

option go_package = "github.com/tokopedia/gripmock/example/multi-files";
option go_package = "github.com/bavix/gripmock/example/multi-files";
// The Gripmock service definition.
service Gripmock1 {
// simple unary method
Expand Down
2 changes: 1 addition & 1 deletion example/multi-files/file2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package multifiles;

option go_package = "github.com/tokopedia/gripmock/example/multi-files";
option go_package = "github.com/bavix/gripmock/example/multi-files";
service Gripmock2 {
// simple unary method
rpc SayHello (Request2) returns (Reply2);
Expand Down
4 changes: 2 additions & 2 deletions example/multi-files/stub/greet1.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method": "SayHello",
"input": {
"equals": {
"name": "tokopedia"
"name": "bavix"
}
},
"output": {
"data": {
"message": "Hello Tokopedia 1",
"message": "Hello bavix 1",
"return_code": 1
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/multi-files/stub/greet2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method": "SayHello",
"input": {
"equals": {
"name": "tokopedia"
"name": "bavix"
}
},
"output": {
"data": {
"message": "Hello Tokopedia 2",
"message": "Hello bavix 2",
"return_code": 1
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/multi-package/bar/bar.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";
package bar;

// this go_package is simulating alias collision
option go_package = "github.com/tokopedia/gripmock/example/multi-package/bar;multi_package";
option go_package = "github.com/bavix/gripmock/example/multi-package/bar;multi_package";

message Bar{
string name = 1;
Expand Down
6 changes: 3 additions & 3 deletions example/multi-package/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"time"

pb "github.com/tokopedia/gripmock/protogen/example/multi-package"
multi_package "github.com/tokopedia/gripmock/protogen/example/multi-package/bar"
pb "github.com/bavix/gripmock/protogen/example/multi-package"
multi_package "github.com/bavix/gripmock/protogen/example/multi-package/bar"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand All @@ -26,7 +26,7 @@ func main() {
c := pb.NewGripmockClient(conn)

// Contact the server and print out its response.
name := "tokopedia"
name := "bavix"
if len(os.Args) > 1 {
name = os.Args[1]
}
Expand Down
4 changes: 2 additions & 2 deletions example/multi-package/stub/simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method":"Greet",
"input":{
"equals":{
"name":"tokopedia"
"name":"bavix"
}
},
"output":{
"data":{
"response":"Hello Tokopedia"
"response":"Hello bavix"
}
}
}
4 changes: 2 additions & 2 deletions example/one-of/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"time"

oneof "github.com/tokopedia/gripmock/protogen/example/one-of"
oneof "github.com/bavix/gripmock/protogen/example/one-of"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand All @@ -25,7 +25,7 @@ func main() {
c := oneof.NewGripmockClient(conn)

// Contact the server and print out its response.
name := "tokopedia"
name := "bavix"
if len(os.Args) > 1 {
name = os.Args[1]
}
Expand Down
2 changes: 1 addition & 1 deletion example/one-of/oneof.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package oneof;

option go_package = "github.com/tokopedia/gripmock/example/one-of";
option go_package = "github.com/bavix/gripmock/example/one-of";

// The Gripmock service definition.
service Gripmock {
Expand Down
2 changes: 1 addition & 1 deletion example/one-of/stub/oneof.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"method":"SayHello",
"input":{
"equals":{
"name":"tokopedia"
"name":"bavix"
}
},
"output":{
Expand Down
4 changes: 2 additions & 2 deletions example/simple/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"time"

pb "github.com/tokopedia/gripmock/protogen/example/simple"
pb "github.com/bavix/gripmock/protogen/example/simple"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand All @@ -25,7 +25,7 @@ func main() {
c := pb.NewGripmockClient(conn)

// Contact the server and print out its response.
name := "tokopedia"
name := "bavix"
if len(os.Args) > 1 {
name = os.Args[1]
}
Expand Down
2 changes: 1 addition & 1 deletion example/simple/simple.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package simple;

option go_package = "github.com/tokopedia/gripmock/example/simple";
option go_package = "github.com/bavix/gripmock/example/simple";

// The Gripmock service definition.
service Gripmock {
Expand Down
4 changes: 2 additions & 2 deletions example/simple/stub/simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"method": "SayHello",
"input": {
"equals": {
"name": "tokopedia"
"name": "bavix"
}
},
"output": {
"data": {
"message": "Hello Tokopedia",
"message": "Hello bavix",
"return_code": 1
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/stream/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

pb "github.com/tokopedia/gripmock/protogen/example/stream"
pb "github.com/bavix/gripmock/protogen/example/stream"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand Down
2 changes: 1 addition & 1 deletion example/stream/stream.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ syntax = "proto3";

package stream;

option go_package = "github.com/tokopedia/gripmock/example/stream";
option go_package = "github.com/bavix/gripmock/example/stream";
// The Gripmock service definition.
service Gripmock {
// server to client sreaming
Expand Down
6 changes: 3 additions & 3 deletions example/stub-subfolders/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

pb "github.com/tokopedia/gripmock/protogen/example/stub-subfolders"
pb "github.com/bavix/gripmock/protogen/example/stub-subfolders"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
Expand All @@ -24,13 +24,13 @@ func main() {
c := pb.NewGripmockClient(conn)

// Contact the server and print out its response.
r, err := c.SayHello(context.Background(), &pb.Request{Name: "tokopedia"})
r, err := c.SayHello(context.Background(), &pb.Request{Name: "bavix"})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
log.Printf("Greeting: %s (return code %d)", r.Message, r.ReturnCode)

r, err = c.SayHello(context.Background(), &pb.Request{Name: "subtokopedia"})
r, err = c.SayHello(context.Background(), &pb.Request{Name: "subbavix"})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions example/stub-subfolders/stub/stub.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method": "SayHello",
"input": {
"equals": {
"name": "tokopedia"
"name": "bavix"
}
},
"output": {
"data": {
"message": "Hello Tokopedia",
"message": "Hello bavix",
"return_code": 1
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"method": "SayHello",
"input": {
"equals": {
"name": "subtokopedia"
"name": "subbavix"
}
},
"output": {
"data": {
"message": "Hello Sub Tokopedia",
"message": "Hello Sub bavix",
"return_code": 1
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/well_known_types/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"time"

pb "github.com/tokopedia/gripmock/protogen/example/well_known_types"
pb "github.com/bavix/gripmock/protogen/example/well_known_types"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
empty "google.golang.org/protobuf/types/known/emptypb"
Expand Down
2 changes: 1 addition & 1 deletion example/well_known_types/wkt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package well_known_types;
import "google/protobuf/empty.proto";
import "google/protobuf/api.proto";

option go_package = "github.com/tokopedia/gripmock/example/well_known_types;wkt";
option go_package = "github.com/bavix/gripmock/example/well_known_types;wkt";
service Gripmock {
// this shows us example on using WKT as dependency
// api.proto in particular has go_package alias with semicolon
Expand Down
2 changes: 1 addition & 1 deletion fix_gopackage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ do
# get the line number of "syntax" declaration
syntaxLineNum="$(grep -n "syntax" "$newfile" | head -n 1 | cut -d: -f1)"

goPackageString="option go_package = \"github.com/tokopedia/gripmock/protogen/$dir\";"
goPackageString="option go_package = \"github.com/bavix/gripmock/protogen/$dir\";"

# append our own go_package delcaration just below "syntax" declaration
sed -i "${syntaxLineNum}s~$~\n$goPackageString~" $newfile
Expand Down
Loading

0 comments on commit 93a6c73

Please sign in to comment.