diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2ea6ba7..6dc0f42 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,5 +15,5 @@ jobs: uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} - - run: go test -v ./... - - run: go vet ./... + - run: go test -v ./pkg/... + - run: go vet ./pkg/... diff --git a/Makefile b/Makefile index ba027da..bd1c047 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ VERSION := $(shell git describe --abbrev=0 --tags) test: - go vet ./... - go test ./... + go vet ./pkg/... + go test ./pkg/... .PHONY: test build-cli: diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 740f054..2f3c826 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -6,7 +6,7 @@ import ( "os" "time" - "github.com/mailsac/dracula/client" + "github.com/mailsac/dracula/pkg/client" ) var ( diff --git a/cmd/server/main.go b/cmd/server/main.go index 032d4a6..c21b3d1 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -3,10 +3,11 @@ package main import ( "flag" "fmt" - "github.com/mailsac/dracula/server" "os" "strings" "sync" + + "github.com/mailsac/dracula/pkg/server" ) var ( diff --git a/go.sum b/go.sum index 1494348..f442dad 100644 --- a/go.sum +++ b/go.sum @@ -61,8 +61,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -185,8 +183,6 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_golang v1.15.0 h1:5fCgGYogn0hFdhyhLbw7hEsWxufKtY9klyvdNfFlFhM= -github.com/prometheus/client_golang v1.15.0/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -208,8 +204,6 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -221,13 +215,11 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -333,7 +325,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -375,10 +366,7 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/client/client.go b/pkg/client/client.go similarity index 98% rename from client/client.go rename to pkg/client/client.go index 652603f..e48ebf0 100644 --- a/client/client.go +++ b/pkg/client/client.go @@ -16,10 +16,10 @@ import ( "sync/atomic" "time" - "github.com/mailsac/dracula/client/serverpool" - "github.com/mailsac/dracula/client/waitingmessage" - "github.com/mailsac/dracula/protocol" - "github.com/mailsac/dracula/server/rawmessage" + "github.com/mailsac/dracula/pkg/client/serverpool" + "github.com/mailsac/dracula/pkg/client/waitingmessage" + "github.com/mailsac/dracula/pkg/protocol" + "github.com/mailsac/dracula/pkg/server/rawmessage" ) var ( diff --git a/client/client_test.go b/pkg/client/client_test.go similarity index 98% rename from client/client_test.go rename to pkg/client/client_test.go index e87189d..fe06556 100644 --- a/client/client_test.go +++ b/pkg/client/client_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/mailsac/dracula/protocol" - "github.com/mailsac/dracula/server" + "github.com/mailsac/dracula/pkg/protocol" + "github.com/mailsac/dracula/pkg/server" "github.com/stretchr/testify/assert" ) diff --git a/client/serverpool/serverpool.go b/pkg/client/serverpool/serverpool.go similarity index 100% rename from client/serverpool/serverpool.go rename to pkg/client/serverpool/serverpool.go diff --git a/client/waitingmessage/waitingmessage.go b/pkg/client/waitingmessage/waitingmessage.go similarity index 100% rename from client/waitingmessage/waitingmessage.go rename to pkg/client/waitingmessage/waitingmessage.go diff --git a/protocol/protocol.go b/pkg/protocol/protocol.go similarity index 100% rename from protocol/protocol.go rename to pkg/protocol/protocol.go diff --git a/protocol/protocol_test.go b/pkg/protocol/protocol_test.go similarity index 100% rename from protocol/protocol_test.go rename to pkg/protocol/protocol_test.go diff --git a/server/rawmessage/rawmessage.go b/pkg/server/rawmessage/rawmessage.go similarity index 97% rename from server/rawmessage/rawmessage.go rename to pkg/server/rawmessage/rawmessage.go index 182b785..17ed086 100644 --- a/server/rawmessage/rawmessage.go +++ b/pkg/server/rawmessage/rawmessage.go @@ -3,11 +3,12 @@ package rawmessage import ( "bufio" "bytes" - "github.com/mailsac/dracula/protocol" "io" "log" "net" "unicode" + + "github.com/mailsac/dracula/pkg/protocol" ) type RawMessage struct { diff --git a/server/restserver.go b/pkg/server/restserver.go similarity index 100% rename from server/restserver.go rename to pkg/server/restserver.go diff --git a/server/server.go b/pkg/server/server.go similarity index 98% rename from server/server.go rename to pkg/server/server.go index fce352d..29bc907 100644 --- a/server/server.go +++ b/pkg/server/server.go @@ -12,9 +12,9 @@ import ( "strconv" "strings" - "github.com/mailsac/dracula/protocol" - "github.com/mailsac/dracula/server/rawmessage" - "github.com/mailsac/dracula/store" + "github.com/mailsac/dracula/pkg/protocol" + "github.com/mailsac/dracula/pkg/server/rawmessage" + "github.com/mailsac/dracula/pkg/store" ) const MinimumExpirySecs = 2 diff --git a/server/server_test.go b/pkg/server/server_test.go similarity index 99% rename from server/server_test.go rename to pkg/server/server_test.go index 3170eff..0c7bca9 100644 --- a/server/server_test.go +++ b/pkg/server/server_test.go @@ -2,12 +2,13 @@ package server import ( "fmt" - "github.com/mailsac/dracula/client" - "github.com/stretchr/testify/assert" "math/rand" "sync" "testing" "time" + + "github.com/mailsac/dracula/pkg/client" + "github.com/stretchr/testify/assert" ) func TestServer_Roundtrip(t *testing.T) { diff --git a/store/store.go b/pkg/store/store.go similarity index 99% rename from store/store.go rename to pkg/store/store.go index 95e47d6..f688674 100644 --- a/store/store.go +++ b/pkg/store/store.go @@ -1,13 +1,14 @@ package store import ( - "github.com/emirpasic/gods/maps/hashmap" - "github.com/mailsac/dracula/store/tree" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" "net/http" "sync" "time" + + "github.com/emirpasic/gods/maps/hashmap" + "github.com/mailsac/dracula/pkg/store/tree" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" ) var runDuration = time.Second * 15 diff --git a/store/tree/tree.go b/pkg/store/tree/tree.go similarity index 100% rename from store/tree/tree.go rename to pkg/store/tree/tree.go diff --git a/store/tree/tree_test.go b/pkg/store/tree/tree_test.go similarity index 100% rename from store/tree/tree_test.go rename to pkg/store/tree/tree_test.go