From 88df080d34aee95f61f3a732cc5773021de0c013 Mon Sep 17 00:00:00 2001 From: Alex Geer Date: Sun, 26 Jun 2022 14:14:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D0=B8=20go=20mod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +++ .testpackages | 36 +++++++++---------- .travis.yml | 3 +- Makefile | 6 ++-- README.md | 4 +-- ambry/ambry.go | 3 -- ambry/ambry_bench_test.go | 12 +++---- ambry/ambry_test.go | 6 +--- ambry/types.go | 2 -- circle.yml | 4 +-- constants.go | 10 ++---- context/context.go | 8 ++--- context/data.go | 6 ++-- context/errors/errors.go | 4 +-- context/errors/types.go | 4 +-- context/handlers/defaults.go | 8 ++--- context/handlers/defaults_test.go | 4 +-- context/handlers/handlers.go | 6 ++-- context/handlers/handlers_test.go | 4 +-- context/handlers/types.go | 6 ++-- context/key.go | 3 -- context/route/route.go | 4 +-- context/route/types.go | 4 +-- context/types.go | 8 ++--- errors.go | 3 -- errors_test.go | 2 -- go.mod | 3 ++ header/header_test.go | 4 --- listen.go | 4 +-- listen_test.go | 3 +- method/method.go | 2 -- method/method_test.go | 2 -- .../contentTypeDefault/contentTypeDefault.go | 6 ++-- .../contentTypeDefault_test.go | 12 +++---- middleware/nocache/nocache.go | 6 ++-- middleware/nocache/nocache_test.go | 14 +++----- middleware/pprof/pprof.go | 8 ++--- middleware/pprof/pprof_test.go | 4 +-- middleware/recovery/recovery.go | 4 +-- middleware/recovery/recovery_test.go | 4 +-- mime/mime_test.go | 4 --- param/param.go | 5 +-- param/param_bench_test.go | 10 +++--- param/param_test.go | 4 +-- param/types.go | 2 -- proxyp/addr_proto_test.go | 4 +-- proxyp/tlvparse/aws.go | 2 +- proxyp/tlvparse/aws_test.go | 2 +- proxyp/tlvparse/ssl.go | 2 +- proxyp/tlvparse/ssl_test.go | 2 +- proxyp/tlvparse/test.go | 2 +- proxyp/version_cmd_test.go | 4 +-- route/chain.go | 2 -- route/route.go | 10 +++--- route/route_basic_test.go | 6 ++-- route/route_interface_test.go | 8 ++--- route/route_subroute_test.go | 8 ++--- route/tree.go | 6 ++-- route/tree_test.go | 10 ++---- route/types.go | 8 ++--- status/status.go | 6 +--- status/status_test.go | 14 ++++---- systemd.go | 2 -- types.go | 8 ++--- utilities.go | 2 -- utilities_test.go | 2 -- web.go | 8 ++--- web_test.go | 2 -- webext.go | 3 +- webext17.go | 7 ++-- webext17_test.go | 11 +----- 71 files changed, 135 insertions(+), 272 deletions(-) create mode 100644 go.mod diff --git a/.gitignore b/.gitignore index 710a5fb..daf3825 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,11 @@ _obj _test src +# IDE +.project +.settings +.idea + # Architecture specific extensions/prefixes *.[568vq] [568vq].out diff --git a/.testpackages b/.testpackages index 10b2575..7176d9c 100644 --- a/.testpackages +++ b/.testpackages @@ -1,18 +1,18 @@ -gopkg.in/webnice/web.v1 -gopkg.in/webnice/web.v1/ambry -gopkg.in/webnice/web.v1/context -gopkg.in/webnice/web.v1/context/errors -gopkg.in/webnice/web.v1/context/handlers -gopkg.in/webnice/web.v1/context/route -gopkg.in/webnice/web.v1/header -gopkg.in/webnice/web.v1/method -gopkg.in/webnice/web.v1/mime -gopkg.in/webnice/web.v1/param -gopkg.in/webnice/web.v1/route -gopkg.in/webnice/web.v1/status -gopkg.in/webnice/web.v1/proxyp -gopkg.in/webnice/web.v1/proxyp/tlvparse -gopkg.in/webnice/web.v1/middleware/recovery -gopkg.in/webnice/web.v1/middleware/pprof -gopkg.in/webnice/web.v1/middleware/nocache -gopkg.in/webnice/web.v1/middleware/contentTypeDefault +github.com/webnice/web +github.com/webnice/web/ambry +github.com/webnice/web/context +github.com/webnice/web/context/errors +github.com/webnice/web/context/handlers +github.com/webnice/web/context/route +github.com/webnice/web/header +github.com/webnice/web/method +github.com/webnice/web/mime +github.com/webnice/web/param +github.com/webnice/web/route +github.com/webnice/web/status +github.com/webnice/web/proxyp +github.com/webnice/web/proxyp/tlvparse +github.com/webnice/web/middleware/recovery +github.com/webnice/web/middleware/pprof +github.com/webnice/web/middleware/nocache +github.com/webnice/web/middleware/contentTypeDefault diff --git a/.travis.yml b/.travis.yml index 67583a9..b630e99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,7 @@ language: go install: - go get github.com/mattn/goveralls - - go get gopkg.in/webnice/debug.v1 - - go get gopkg.in/webnice/log.v2 + - go get github.com/webnice/debug script: - make test diff --git a/Makefile b/Makefile index 7b3202d..02f1fe7 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ GO111MODULE ?= $(GO111MODULE:on) default: help link: - @mkdir -p src/gopkg.in/webnice; cd src/gopkg.in/webnice && ln -s ../../.. web.v1 2>/dev/null; true + @mkdir -p src/github.com/webnice; cd src/github.com/webnice && ln -s ../../.. web 2>/dev/null; true .PHONY: link ## Code generation (run only during development) @@ -30,7 +30,7 @@ test: link @echo "mode: set" > coverage.log @for PACKET in $(TESTPACKETS); do \ touch coverage-tmp.log; \ - GOPATH=${GOPATH} go test -v -covermode=count -coverprofile=coverage-tmp.log $$PACKET; \ + GO111MODULE="off" go test -v -covermode=count -coverprofile=coverage-tmp.log $$PACKET; \ if [ "$$?" -ne "0" ]; then exit $$?; fi; \ tail -n +2 coverage-tmp.log | sort -r | awk '{if($$1 != last) {print $$0;last=$$1}}' >> coverage.log; \ rm -f coverage-tmp.log; true; \ @@ -39,7 +39,7 @@ test: link ## Displaying in the browser coverage of tested code, on the html report (run only during development) cover: test - @GOPATH=${GOPATH} go tool cover -html=$(DIR)/coverage.log + @GOPATH=${GOPATH} GO111MODULE="off" go tool cover -html=$(DIR)/coverage.log .PHONY: cover ## Performance testing diff --git a/README.md b/README.md index e5ce22d..7d5b0d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # web -[![GoDoc](https://godoc.org/gopkg.in/webnice/web.v1?status.png)](http://godoc.org/gopkg.in/webnice/web.v1) +[![GoDoc](https://godoc.org/github.com/webnice/web?status.png)](http://godoc.org/github.com/webnice/web) [![Go Report Card](https://goreportcard.com/badge/github.com/webnice/web)](https://goreportcard.com/report/github.com/webnice/web) [![Coverage Status](https://coveralls.io/repos/github/webnice/web/badge.svg?branch=v1)](https://coveralls.io/github/webnice/web?branch=v1) [![Build Status](https://travis-ci.org/webnice/web.svg?branch=v1)](https://travis-ci.org/webnice/web) @@ -20,5 +20,5 @@ But at the same time framework adds to your application a full-functions routing #### Install ```bash -go get gopkg.in/webnice/web.v1 +go get github.com/webnice/web ``` diff --git a/ambry/ambry.go b/ambry/ambry.go index 672c7ea..27c0623 100644 --- a/ambry/ambry.go +++ b/ambry/ambry.go @@ -1,8 +1,5 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // New is a constructor func New() Interface { var itm = new(impl) diff --git a/ambry/ambry_bench_test.go b/ambry/ambry_bench_test.go index 50c79a1..6b8140a 100644 --- a/ambry/ambry_bench_test.go +++ b/ambry/ambry_bench_test.go @@ -1,13 +1,11 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "testing" -) +import "testing" -const KEY = "foo" -const VAL = "bar" +const ( + KEY = "foo" + VAL = "bar" +) var res interface{} diff --git a/ambry/ambry_test.go b/ambry/ambry_test.go index 83eee7f..5ae10b3 100644 --- a/ambry/ambry_test.go +++ b/ambry/ambry_test.go @@ -1,10 +1,6 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "testing" -) +import "testing" var ( k = `A69F2F4D-0B8F-43D3-8E1B-1EA90766FEB5` diff --git a/ambry/types.go b/ambry/types.go index e44cfa4..81a8fc2 100644 --- a/ambry/types.go +++ b/ambry/types.go @@ -1,7 +1,5 @@ package ambry -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import "sync" // Interface is an interface of package diff --git a/circle.yml b/circle.yml index 69e72c4..2aa39e7 100644 --- a/circle.yml +++ b/circle.yml @@ -1,7 +1,7 @@ dependencies: override: - - mkdir -p src/gopkg.in/webnice - - cd src/gopkg.in/webnice && ln -s ../../.. web.v1 2>/dev/null + - mkdir -p src/github.com/webnice + - cd src/github.com/webnice && ln -s ../../.. web 2>/dev/null test: override: diff --git a/constants.go b/constants.go index 8125df3..d8a1635 100644 --- a/constants.go +++ b/constants.go @@ -1,11 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "time" -) +import "time" -const ( - shutdownTimeout time.Duration = time.Minute / 2 -) +const shutdownTimeout time.Duration = time.Minute / 2 diff --git a/context/context.go b/context/context.go index a461899..e8b0588 100644 --- a/context/context.go +++ b/context/context.go @@ -1,14 +1,12 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( stdContext "context" "net/http" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/context/route" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/context/route" ) // New returns a new routing context object diff --git a/context/data.go b/context/data.go index c580b95..6053ae0 100644 --- a/context/data.go +++ b/context/data.go @@ -1,7 +1,5 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "bytes" "encoding/json" @@ -12,8 +10,8 @@ import ( runtimeDebug "runtime/debug" "strings" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/mime" + "github.com/webnice/web/header" + "github.com/webnice/web/mime" ) // RegisterGlobalVerifyPlugin Register global external library of data verification diff --git a/context/errors/errors.go b/context/errors/errors.go index ace52a4..9ad4add 100644 --- a/context/errors/errors.go +++ b/context/errors/errors.go @@ -1,8 +1,6 @@ package errors -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import "gopkg.in/webnice/web.v1/ambry" +import "github.com/webnice/web/ambry" // New returns new context object func New() Interface { diff --git a/context/errors/types.go b/context/errors/types.go index 21e822f..7fa9232 100644 --- a/context/errors/types.go +++ b/context/errors/types.go @@ -1,8 +1,6 @@ package errors -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import "gopkg.in/webnice/web.v1/ambry" +import "github.com/webnice/web/ambry" const ( keyRouteConfigurationError uint32 = iota diff --git a/context/handlers/defaults.go b/context/handlers/defaults.go index d1d60ee..99c0c16 100644 --- a/context/handlers/defaults.go +++ b/context/handlers/defaults.go @@ -1,13 +1,11 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/mime" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/mime" + "github.com/webnice/web/status" ) // Default handler for internal server errors diff --git a/context/handlers/defaults_test.go b/context/handlers/defaults_test.go index 90f7be2..660502f 100644 --- a/context/handlers/defaults_test.go +++ b/context/handlers/defaults_test.go @@ -1,7 +1,5 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -9,7 +7,7 @@ import ( "net/http/httptest" "testing" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/context/errors" ) func testDefaults(t *testing.T, handler http.HandlerFunc, hfName string, response string) { diff --git a/context/handlers/handlers.go b/context/handlers/handlers.go index 8de2ed2..c948763 100644 --- a/context/handlers/handlers.go +++ b/context/handlers/handlers.go @@ -1,12 +1,10 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/ambry" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/ambry" + "github.com/webnice/web/context/errors" ) // New returns new context object diff --git a/context/handlers/handlers_test.go b/context/handlers/handlers_test.go index 7930538..59de976 100644 --- a/context/handlers/handlers_test.go +++ b/context/handlers/handlers_test.go @@ -1,13 +1,11 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" "testing" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/context/errors" ) type testHandler struct { diff --git a/context/handlers/types.go b/context/handlers/types.go index 1f33020..020df83 100644 --- a/context/handlers/types.go +++ b/context/handlers/types.go @@ -1,12 +1,10 @@ package handlers -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/ambry" - "gopkg.in/webnice/web.v1/context/errors" + "github.com/webnice/web/ambry" + "github.com/webnice/web/context/errors" ) const ( diff --git a/context/key.go b/context/key.go index c690720..1abfe08 100644 --- a/context/key.go +++ b/context/key.go @@ -1,8 +1,5 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // key is a value for use with context.WithValue // It's used as a pointer so it fits in an interface{} without allocation type key struct { diff --git a/context/route/route.go b/context/route/route.go index 6093c31..f33f5f6 100644 --- a/context/route/route.go +++ b/context/route/route.go @@ -1,11 +1,9 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "strings" - "gopkg.in/webnice/web.v1/param" + "github.com/webnice/web/param" ) // New returns a new routing context object diff --git a/context/route/types.go b/context/route/types.go index c5746fd..91de22e 100644 --- a/context/route/types.go +++ b/context/route/types.go @@ -1,8 +1,6 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import "gopkg.in/webnice/web.v1/param" +import "github.com/webnice/web/param" // This is the default routing context set on the root node of a request context to track URL parameters and an optional routing path type impl struct { diff --git a/context/types.go b/context/types.go index 4e65ee2..a8b7336 100644 --- a/context/types.go +++ b/context/types.go @@ -1,13 +1,11 @@ package context -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "net/http" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/context/route" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/context/route" ) var ( diff --git a/errors.go b/errors.go index 1af7fa3..04a1f67 100644 --- a/errors.go +++ b/errors.go @@ -1,8 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // All errors are defined as constants const ( cAlreadyRunning = `Web server already running` diff --git a/errors_test.go b/errors_test.go index 8de1b4f..4f55c1f 100644 --- a/errors_test.go +++ b/errors_test.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "strings" "testing" diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..de619c9 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/webnice/web + +go 1.18 diff --git a/header/header_test.go b/header/header_test.go index 2ed5bf4..78347ba 100644 --- a/header/header_test.go +++ b/header/header_test.go @@ -1,5 +1 @@ package header - -//import ( -// -//) diff --git a/listen.go b/listen.go index e31971d..af8a614 100644 --- a/listen.go +++ b/listen.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "crypto/tls" "net" @@ -176,7 +174,7 @@ func (wsv *web) Serve(ltn net.Listener) Interface { return wsv.ServeTLS(ltn, nil func (wsv *web) ServeTLS(ltn net.Listener, tlsConfig *tls.Config) Interface { var conf *Configuration - // TODO: Реализовать поддержку PROXY Protocol через "gopkg.in/webnice/web.v1/proxyp", conf.ProxyProtocol + // TODO: Реализовать поддержку PROXY Protocol через "github.com/webnice/web/proxyp", conf.ProxyProtocol if wsv.conf == nil { conf, _ = parseAddress(ltn.Addr().String()) diff --git a/listen_test.go b/listen_test.go index e681672..a918486 100644 --- a/listen_test.go +++ b/listen_test.go @@ -1,9 +1,8 @@ +//go:build !race // +build !race package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net" diff --git a/method/method.go b/method/method.go index 663e774..3acd557 100644 --- a/method/method.go +++ b/method/method.go @@ -1,7 +1,5 @@ package method -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "strings" diff --git a/method/method_test.go b/method/method_test.go index 70e3ecc..cd1d4d9 100644 --- a/method/method_test.go +++ b/method/method_test.go @@ -1,7 +1,5 @@ package method -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "strings" "testing" diff --git a/middleware/contentTypeDefault/contentTypeDefault.go b/middleware/contentTypeDefault/contentTypeDefault.go index 21ab842..f40d956 100644 --- a/middleware/contentTypeDefault/contentTypeDefault.go +++ b/middleware/contentTypeDefault/contentTypeDefault.go @@ -1,13 +1,11 @@ package contentTypeDefault -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "io" "net/http" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/status" ) // Interface is an interface of package diff --git a/middleware/contentTypeDefault/contentTypeDefault_test.go b/middleware/contentTypeDefault/contentTypeDefault_test.go index fed87c1..5abba75 100644 --- a/middleware/contentTypeDefault/contentTypeDefault_test.go +++ b/middleware/contentTypeDefault/contentTypeDefault_test.go @@ -1,7 +1,5 @@ package contentTypeDefault -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -9,10 +7,10 @@ import ( "net/http/httptest" "testing" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/mime" - "gopkg.in/webnice/web.v1/route" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/mime" + "github.com/webnice/web/route" + "github.com/webnice/web/status" ) func testContentTypeDefaultHandlerFunc1(wr http.ResponseWriter, rq *http.Request) { @@ -43,7 +41,7 @@ func testContentTypeDefault(t *testing.T, rou route.Interface, hf http.HandlerFu err = fmt.Errorf("response HandlerFunc error: %s", err) return } - defer rsp.Body.Close() + defer func() { _ = rsp.Body.Close() }() if buf, err = ioutil.ReadAll(rsp.Body); err != nil { err = fmt.Errorf("read response error: %s", err) diff --git a/middleware/nocache/nocache.go b/middleware/nocache/nocache.go index 579a184..faa7804 100644 --- a/middleware/nocache/nocache.go +++ b/middleware/nocache/nocache.go @@ -1,14 +1,12 @@ package nocache -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "io" "net/http" "time" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/status" ) type impl struct { diff --git a/middleware/nocache/nocache_test.go b/middleware/nocache/nocache_test.go index 8090ea7..68beccd 100644 --- a/middleware/nocache/nocache_test.go +++ b/middleware/nocache/nocache_test.go @@ -1,7 +1,5 @@ package nocache -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -10,20 +8,18 @@ import ( "testing" "time" - "gopkg.in/webnice/web.v1/header" - "gopkg.in/webnice/web.v1/route" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/header" + "github.com/webnice/web/route" + "github.com/webnice/web/status" ) -const ( - ifModifiedSinceTimeFormat = `Mon, 02 Jan 2006 15:04:05 GMT` -) +const ifModifiedSinceTimeFormat = `Mon, 02 Jan 2006 15:04:05 GMT` func testNoCacheHandlerFunc(wr http.ResponseWriter, rq *http.Request) { wr.Header().Add(header.ETag, "686897696a7c876b7e") wr.Header().Set(header.LastModified, time.Now().UTC().Format(ifModifiedSinceTimeFormat)) wr.Header().Set(header.IfUnmodifiedSince, time.Now().UTC().Format(ifModifiedSinceTimeFormat)) - fmt.Fprint(wr, string(status.Bytes(status.Ok))) + _, _ = fmt.Fprint(wr, string(status.Bytes(status.Ok))) wr.WriteHeader(status.Ok) } diff --git a/middleware/pprof/pprof.go b/middleware/pprof/pprof.go index ee2102d..96be2fb 100644 --- a/middleware/pprof/pprof.go +++ b/middleware/pprof/pprof.go @@ -1,16 +1,14 @@ package pprof -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "expvar" "fmt" "net/http" "net/http/pprof" - "gopkg.in/webnice/web.v1/middleware/nocache" - "gopkg.in/webnice/web.v1/route" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/middleware/nocache" + "github.com/webnice/web/route" + "github.com/webnice/web/status" ) // Handler Middleware to profiling diff --git a/middleware/pprof/pprof_test.go b/middleware/pprof/pprof_test.go index dd652ae..713f11a 100644 --- a/middleware/pprof/pprof_test.go +++ b/middleware/pprof/pprof_test.go @@ -1,7 +1,5 @@ package pprof -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -10,7 +8,7 @@ import ( "strings" "testing" - "gopkg.in/webnice/web.v1/route" + "github.com/webnice/web/route" ) const testTitleString = `/debug/pprof/` diff --git a/middleware/recovery/recovery.go b/middleware/recovery/recovery.go index 8add680..ded06c3 100644 --- a/middleware/recovery/recovery.go +++ b/middleware/recovery/recovery.go @@ -1,13 +1,11 @@ package recovery -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" runtimeDebug "runtime/debug" - "gopkg.in/webnice/web.v1/context" + "github.com/webnice/web/context" ) // Handler is a middleware that recovers from panics diff --git a/middleware/recovery/recovery_test.go b/middleware/recovery/recovery_test.go index 3d05887..f4f5076 100644 --- a/middleware/recovery/recovery_test.go +++ b/middleware/recovery/recovery_test.go @@ -1,7 +1,5 @@ package recovery -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "io/ioutil" @@ -10,7 +8,7 @@ import ( "strings" "testing" - "gopkg.in/webnice/web.v1/route" + "github.com/webnice/web/route" ) const ( diff --git a/mime/mime_test.go b/mime/mime_test.go index 0997075..9d54722 100644 --- a/mime/mime_test.go +++ b/mime/mime_test.go @@ -1,5 +1 @@ package mime - -//import ( -// -//) diff --git a/param/param.go b/param/param.go index 9bea260..888d40a 100644 --- a/param/param.go +++ b/param/param.go @@ -1,8 +1,5 @@ package param -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" - // New is a constructor func New() Interface { var itm = new(impl) @@ -91,7 +88,7 @@ func (itm *impl) Keys() (ret []string) { return } -// Get gets the all value associated with the given key. +// GetAll Get gets the all value associated with the given key. // If there are no values associated with the key, Get returns empty slice func (itm *impl) GetAll(k string) (ret []string) { var value []*item diff --git a/param/param_bench_test.go b/param/param_bench_test.go index fc372c4..9546c39 100644 --- a/param/param_bench_test.go +++ b/param/param_bench_test.go @@ -1,11 +1,11 @@ package param -import ( - "testing" -) +import "testing" -const KEY = "foo" -const VAL = "bar" +const ( + KEY = "foo" + VAL = "bar" +) var res interface{} diff --git a/param/param_test.go b/param/param_test.go index 05dfdb4..ec912ca 100644 --- a/param/param_test.go +++ b/param/param_test.go @@ -1,8 +1,6 @@ package param -import ( - "testing" -) +import "testing" var ( k = `A69F2F4D-0B8F-43D3-8E1B-1EA90766FEB5` diff --git a/param/types.go b/param/types.go index 359d6b5..84e981d 100644 --- a/param/types.go +++ b/param/types.go @@ -1,7 +1,5 @@ package param -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import "sync" type ( diff --git a/proxyp/addr_proto_test.go b/proxyp/addr_proto_test.go index 436be51..f31d9fc 100644 --- a/proxyp/addr_proto_test.go +++ b/proxyp/addr_proto_test.go @@ -1,8 +1,6 @@ package proxyproto -import ( - "testing" -) +import "testing" func TestTCPoverIPv4(t *testing.T) { b := byte(TCPv4) diff --git a/proxyp/tlvparse/aws.go b/proxyp/tlvparse/aws.go index be9047b..a597b0d 100644 --- a/proxyp/tlvparse/aws.go +++ b/proxyp/tlvparse/aws.go @@ -6,7 +6,7 @@ package tlvparse import ( "regexp" - "gopkg.in/webnice/web.v1/proxyp" + "github.com/webnice/web/proxyp" ) const ( diff --git a/proxyp/tlvparse/aws_test.go b/proxyp/tlvparse/aws_test.go index 4d84dd1..21e6577 100644 --- a/proxyp/tlvparse/aws_test.go +++ b/proxyp/tlvparse/aws_test.go @@ -4,7 +4,7 @@ import ( "encoding/binary" "testing" - "gopkg.in/webnice/web.v1/proxyp" + "github.com/webnice/web/proxyp" ) var awsTestCases = []struct { diff --git a/proxyp/tlvparse/ssl.go b/proxyp/tlvparse/ssl.go index 77c9c08..9257f82 100644 --- a/proxyp/tlvparse/ssl.go +++ b/proxyp/tlvparse/ssl.go @@ -5,7 +5,7 @@ import ( "unicode" "unicode/utf8" - "gopkg.in/webnice/web.v1/proxyp" + "github.com/webnice/web/proxyp" ) const ( diff --git a/proxyp/tlvparse/ssl_test.go b/proxyp/tlvparse/ssl_test.go index 5234bbd..a6d374f 100644 --- a/proxyp/tlvparse/ssl_test.go +++ b/proxyp/tlvparse/ssl_test.go @@ -3,7 +3,7 @@ package tlvparse import ( "testing" - "gopkg.in/webnice/web.v1/proxyp" + "github.com/webnice/web/proxyp" ) var testCases = []struct { diff --git a/proxyp/tlvparse/test.go b/proxyp/tlvparse/test.go index 2788eee..cb890e5 100644 --- a/proxyp/tlvparse/test.go +++ b/proxyp/tlvparse/test.go @@ -5,7 +5,7 @@ import ( "bytes" "testing" - "gopkg.in/webnice/web.v1/proxyp" + "github.com/webnice/web/proxyp" ) func checkTLVs(t *testing.T, name string, raw []byte, expected []proxyproto.PP2Type) []proxyproto.TLV { diff --git a/proxyp/version_cmd_test.go b/proxyp/version_cmd_test.go index 19fac7e..0872da9 100644 --- a/proxyp/version_cmd_test.go +++ b/proxyp/version_cmd_test.go @@ -1,8 +1,6 @@ package proxyproto -import ( - "testing" -) +import "testing" func TestLocal(t *testing.T) { b := byte(LOCAL) diff --git a/route/chain.go b/route/chain.go index 51018aa..da7de01 100644 --- a/route/chain.go +++ b/route/chain.go @@ -1,7 +1,5 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import "net/http" // ChainHandler is a type of chain handlers diff --git a/route/route.go b/route/route.go index 1c8553c..4b2e03f 100644 --- a/route/route.go +++ b/route/route.go @@ -1,16 +1,14 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" "runtime" - "gopkg.in/webnice/web.v1/context" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/method" + "github.com/webnice/web/context" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/method" ) // New returns a newly initialized router object that implements the Router interface diff --git a/route/route_basic_test.go b/route/route_basic_test.go index f1a2252..1022264 100644 --- a/route/route_basic_test.go +++ b/route/route_basic_test.go @@ -1,7 +1,5 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "bufio" "bytes" @@ -11,8 +9,8 @@ import ( "strings" "testing" - "gopkg.in/webnice/web.v1/context" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/context" + "github.com/webnice/web/status" ) func testRequest(t *testing.T, method string, path string, body *bytes.Buffer) (rsp *http.Response, ret *bytes.Buffer, err error) { diff --git a/route/route_interface_test.go b/route/route_interface_test.go index 51e0a9d..f2ba786 100644 --- a/route/route_interface_test.go +++ b/route/route_interface_test.go @@ -1,7 +1,5 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "bytes" "net/http" @@ -9,12 +7,10 @@ import ( "strings" "testing" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/status" ) -var ( - testMiddlewareCount int64 -) +var testMiddlewareCount int64 func testMiddlewareCounter(next http.Handler) http.Handler { return http.HandlerFunc(func(wr http.ResponseWriter, rq *http.Request) { diff --git a/route/route_subroute_test.go b/route/route_subroute_test.go index 8803c3f..605bd2c 100644 --- a/route/route_subroute_test.go +++ b/route/route_subroute_test.go @@ -1,16 +1,14 @@ package route -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "bytes" "net/http" "net/http/httptest" "testing" - "gopkg.in/webnice/web.v1/context" - "gopkg.in/webnice/web.v1/method" - "gopkg.in/webnice/web.v1/status" + "github.com/webnice/web/context" + "github.com/webnice/web/method" + "github.com/webnice/web/status" ) var countTestSubroute int64 diff --git a/route/tree.go b/route/tree.go index 6b9235e..51acdf8 100644 --- a/route/tree.go +++ b/route/tree.go @@ -4,16 +4,14 @@ package route // Armon Dadgar in https://github.com/armon/go-radix/blob/master/radix.go // (MIT licensed). -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" "sort" "strings" - "gopkg.in/webnice/web.v1/context" - "gopkg.in/webnice/web.v1/method" + "github.com/webnice/web/context" + "github.com/webnice/web/method" ) const ( diff --git a/route/tree_test.go b/route/tree_test.go index 7945080..e943e02 100644 --- a/route/tree_test.go +++ b/route/tree_test.go @@ -4,20 +4,16 @@ package route // Armon Dadgar in https://github.com/armon/go-radix/blob/master/radix.go // (MIT licensed). -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" "testing" - "gopkg.in/webnice/web.v1/context" - "gopkg.in/webnice/web.v1/method" + "github.com/webnice/web/context" + "github.com/webnice/web/method" ) -var ( - emptyParams = map[string]string{} -) +var emptyParams = map[string]string{} func TestTree(t *testing.T) { hStub := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) diff --git a/route/types.go b/route/types.go index 765afd8..472cae4 100644 --- a/route/types.go +++ b/route/types.go @@ -1,14 +1,12 @@ package route -// import "gopkg.in/webnice/debug.v1" -// import "gopkg.in/webnice/log.v2" import ( "net/http" "sync" - "gopkg.in/webnice/web.v1/context" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" + "github.com/webnice/web/context" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" ) // Interface is an interface of router consisting of the core routing methods, using only the standard net/http diff --git a/status/status.go b/status/status.go index 134a58f..4e24a58 100644 --- a/status/status.go +++ b/status/status.go @@ -1,10 +1,6 @@ package status -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "fmt" -) +import "fmt" // Text returns a text for the HTTP status code as string // If the code is unknown, return "HTTP status code %d" diff --git a/status/status_test.go b/status/status_test.go index 9558489..2e210c2 100644 --- a/status/status_test.go +++ b/status/status_test.go @@ -1,15 +1,13 @@ package status -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "testing" -) +import "testing" func TestStatus(tst *testing.T) { - var v int - var t string - var b []byte + var ( + v int + t string + b []byte + ) v = Ok t = Text(v) diff --git a/systemd.go b/systemd.go index de82f25..a000cff 100644 --- a/systemd.go +++ b/systemd.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "crypto/tls" "fmt" diff --git a/types.go b/types.go index 24ac704..33fe33f 100644 --- a/types.go +++ b/types.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "crypto/tls" "net" @@ -10,9 +8,9 @@ import ( "sync/atomic" "time" - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/route" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/route" ) const ( diff --git a/utilities.go b/utilities.go index bb84876..a405111 100644 --- a/utilities.go +++ b/utilities.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net" diff --git a/utilities_test.go b/utilities_test.go index 9aa730c..a70da60 100644 --- a/utilities_test.go +++ b/utilities_test.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "net/http" diff --git a/web.go b/web.go index e080da0..dceb4b5 100644 --- a/web.go +++ b/web.go @@ -1,11 +1,9 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( - "gopkg.in/webnice/web.v1/context/errors" - "gopkg.in/webnice/web.v1/context/handlers" - "gopkg.in/webnice/web.v1/route" + "github.com/webnice/web/context/errors" + "github.com/webnice/web/context/handlers" + "github.com/webnice/web/route" ) // New is a constructor of new web server implementation diff --git a/web_test.go b/web_test.go index 73d1941..8dfc799 100644 --- a/web_test.go +++ b/web_test.go @@ -1,7 +1,5 @@ package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "fmt" "testing" diff --git a/webext.go b/webext.go index 0e0d7b1..ad20d6e 100644 --- a/webext.go +++ b/webext.go @@ -1,9 +1,8 @@ +//go:build go1.8 // +build go1.8 package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" import ( "context" "crypto/tls" diff --git a/webext17.go b/webext17.go index 442b5da..74cb8e1 100644 --- a/webext17.go +++ b/webext17.go @@ -1,12 +1,9 @@ +//go:build go1.7 && !go1.8 // +build go1.7,!go1.8 package web -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -import ( - "net/http" -) +import "net/http" // Stop web server func (wsv *web) Stop() Interface { diff --git a/webext17_test.go b/webext17_test.go index 5605af8..4a3266c 100644 --- a/webext17_test.go +++ b/webext17_test.go @@ -1,13 +1,4 @@ +//go:build go1.7 && !go1.8 // +build go1.7,!go1.8 package web - -//import "gopkg.in/webnice/debug.v1" -//import "gopkg.in/webnice/log.v2" -//import ( -// "testing" -//) - -//func TestStop(t *testing.T) { -// -//}