Skip to content

Commit

Permalink
Add Go module support (#95)
Browse files Browse the repository at this point in the history
* Add Go module file

- add go.mod
- regenerate files using the current versions of statik and protoc-gen-go
- update vendored libraries (run `go mod vendor`)

* Travis: add Go 1.12
  • Loading branch information
IngmarStein authored and colonelxc committed Mar 18, 2019
1 parent 0feabcc commit 92a16cf
Show file tree
Hide file tree
Showing 149 changed files with 43,378 additions and 22,150 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: go

go:
- "1.8"
- "1.9"
- "1.10"
- "1.11"
- "1.12"

script:
- test -z "$(gofmt -s -l $(find . -name '*.go' -type f -not -path "./vendor/*" -not -name "*.pb.go" -print) | tee /dev/stderr)"
Expand Down
22 changes: 4 additions & 18 deletions api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"reflect"
"testing"

pb "github.com/google/safebrowsing/internal/safebrowsing_proto"
Expand Down Expand Up @@ -88,10 +87,10 @@ func TestNetAPI(t *testing.T) {
if err != nil {
t.Errorf("unexpected ListUpdate error: %v", err)
}
if !reflect.DeepEqual(gotReq, wantReq) {
if !proto.Equal(gotReq, wantReq) {
t.Errorf("mismatching ListUpdate requests:\ngot %+v\nwant %+v", gotReq, wantReq)
}
if !reflect.DeepEqual(gotResp, wantResp) {
if !proto.Equal(gotResp, wantResp) {
t.Errorf("mismatching ListUpdate responses:\ngot %+v\nwant %+v", gotResp, wantResp)
}

Expand All @@ -113,10 +112,10 @@ func TestNetAPI(t *testing.T) {
if err != nil {
t.Errorf("unexpected HashLookup error: %v", err)
}
if !reflect.DeepEqual(gotReq, wantReq) {
if !proto.Equal(gotReq, wantReq) {
t.Errorf("mismatching HashLookup requests:\ngot %+v\nwant %+v", gotReq, wantReq)
}
if !reflect.DeepEqual(gotResp, wantResp) {
if !proto.Equal(gotResp, wantResp) {
t.Errorf("mismatching HashLookup responses:\ngot %+v\nwant %+v", gotResp, wantResp)
}

Expand All @@ -139,17 +138,4 @@ func TestNetAPI(t *testing.T) {
if err == nil {
t.Errorf("unexpected HashLookup success, wanted HTTP request canceled")
}

// Test for detection of incorrect protobufs.
wantReq = &pb.FindFullHashesRequest{ThreatInfo: &pb.ThreatInfo{
ThreatEntryTypes: []pb.ThreatEntryType{7, 8, 9},
}}
wantResp = &pb.FetchThreatListUpdatesResponse{ListUpdateResponses: []*pb.FetchThreatListUpdatesResponse_ListUpdateResponse{
{ThreatType: 1, PlatformType: 2, ThreatEntryType: 3, ResponseType: 1},
}}
gotReq = &pb.FindFullHashesRequest{}
_, err = api.HashLookup(context.Background(), wantReq.(*pb.FindFullHashesRequest))
if err == nil {
t.Errorf("unexpected HashLookup success")
}
}
5 changes: 4 additions & 1 deletion cmd/sbserver/statik/statik.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/google/safebrowsing

require (
github.com/golang/protobuf v1.2.0
github.com/rakyll/statik v0.1.5
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect
golang.org/x/text v0.3.0 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/rakyll/statik v0.1.5 h1:Ly2UjURzxnsSYS0zI50fZ+srA+Fu7EbpV5hglvJvJG0=
github.com/rakyll/statik v0.1.5/go.mod h1:OEi9wJV/fMUAGx1eNjq75DKDsJVuEv1U0oYdX6GX8Zs=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd h1:HuTn7WObtcDo9uEEU7rEqL0jYthdXAmZ6PP+meazmaU=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Loading

0 comments on commit 92a16cf

Please sign in to comment.