diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
deleted file mode 100644
index 3c1c0dc4..00000000
--- a/.github/workflows/go.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-name: Go
-on: [push]
-env:
- GOPROXY: "https://goproxy.io"
-jobs:
-
- build:
- name: Build
- runs-on: ubuntu-latest
- steps:
-
- - uses: actions/cache@v1
- id: cache
- with:
- path: ~/go/pkg/mod
- key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
- restore-keys: |
- ${{ runner.os }}-go-
-
- - name: Set up Go 1.14
- uses: actions/setup-go@v1
- with:
- go-version: 1.14
- id: go
-
- - name: Check out code into the Go module directory
- uses: actions/checkout@master
-
- # - name: Get dependencies
- # run: |
- # go get -v -t -d ./...
- - name: Build
- run: go build -v .
\ No newline at end of file
diff --git a/README.md b/README.md
index 2aafdc7a..fea42d32 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
# Iris Web Framework
-[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![FOSSA Status](https://img.shields.io/badge/LICENSE%20SCAN-PASSING❤️-CD2956?style=for-the-badge&logo=fossa)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Firis?ref=badge_shield) [![view examples](https://img.shields.io/badge/learn%20by-examples-0C8EC5.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=7E18DD&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community)
+[![build status](https://img.shields.io/travis/kataras/iris/master.svg?style=for-the-badge&logo=travis)](https://travis-ci.org/kataras/iris) [![view examples](https://img.shields.io/badge/examples%20-173-a83adf.svg?style=for-the-badge&logo=go)](https://github.com/kataras/iris/tree/master/_examples) [![chat](https://img.shields.io/gitter/room/iris_go/community.svg?color=cc2b5e&logo=gitter&style=for-the-badge)](https://gitter.im/iris_go/community) [![donate](https://img.shields.io/badge/support-Iris-blue.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/kataras)
diff --git a/_examples/mvc/grpc-compatible/helloworld/helloworld.pb.go b/_examples/mvc/grpc-compatible/helloworld/helloworld.pb.go
index cb1276bc..6be07b7c 100644
--- a/_examples/mvc/grpc-compatible/helloworld/helloworld.pb.go
+++ b/_examples/mvc/grpc-compatible/helloworld/helloworld.pb.go
@@ -22,7 +22,6 @@ package helloworld
import (
context "context"
- proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
@@ -39,10 +38,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
-// This is a compile-time assertion that a sufficiently up-to-date version
-// of the legacy proto package is being used.
-const _ = proto.ProtoPackageIsVersion4
-
// The request message containing the user's name.
type HelloRequest struct {
state protoimpl.MessageState
diff --git a/cache/client/client.go b/cache/client/client.go
index 50bf76ef..cb572cfd 100644
--- a/cache/client/client.go
+++ b/cache/client/client.go
@@ -153,10 +153,11 @@ func (h *ClientHandler) ServeHTTP(ctx context.Context) {
return
}
// go Client.Do(request)
- _, err = Client.Do(request)
+ resp, err := Client.Do(request)
if err != nil {
return
}
+ resp.Body.Close()
} else {
// get the status code , content type and the write the response body
ctx.ContentType(response.Header.Get(cfg.ContentTypeHeader))
diff --git a/configuration.go b/configuration.go
index 2f890c30..b6176569 100644
--- a/configuration.go
+++ b/configuration.go
@@ -530,7 +530,7 @@ func WithSitemap(startURL string) Configurator {
handler := func(ctx Context) {
ctx.ContentType(context.ContentXMLHeaderValue)
- ctx.Write(contentCopy)
+ ctx.Write(contentCopy) // nolint:errcheck
}
if app.builded {
routes := app.CreateRoutes([]string{MethodGet, MethodHead, MethodOptions}, s.Path, handler)
@@ -625,7 +625,8 @@ func (tc *TunnelingConfiguration) isEnabled() bool {
}
func (tc *TunnelingConfiguration) isNgrokRunning() bool {
- _, err := http.Get(tc.WebInterface)
+ resp, err := http.Get(tc.WebInterface)
+ resp.Body.Close()
return err == nil
}
@@ -723,6 +724,7 @@ func (tc TunnelingConfiguration) stopTunnel(t Tunnel) error {
if err != nil {
return err
}
+ defer resp.Body.Close()
if resp.StatusCode != StatusNoContent {
return fmt.Errorf("stop return an unexpected status code: %d", resp.StatusCode)
@@ -904,7 +906,7 @@ type Configuration struct {
DisableBodyConsumptionOnUnmarshal bool `json:"disableBodyConsumptionOnUnmarshal,omitempty" yaml:"DisableBodyConsumptionOnUnmarshal" toml:"DisableBodyConsumptionOnUnmarshal"`
// FireEmptyFormError returns if set to tue true then the `context.ReadBody/ReadForm`
// will return an `iris.ErrEmptyForm` on empty request form data.
- FireEmptyFormError bool `json:"fireEmptyFormError,omitempty" yaml:"FireEmptyFormError" yaml:"FireEmptyFormError"`
+ FireEmptyFormError bool `json:"fireEmptyFormError,omitempty" yaml:"FireEmptyFormError" toml:"FireEmptyFormError"`
// TimeFormat time format for any kind of datetime parsing
// Defaults to "Mon, 02 Jan 2006 15:04:05 GMT".
diff --git a/context/context.go b/context/context.go
index 663241a8..2269fb27 100644
--- a/context/context.go
+++ b/context/context.go
@@ -30,7 +30,6 @@ import (
"github.com/Shopify/goreferrer"
"github.com/fatih/structs"
- "github.com/golang/protobuf/proto"
"github.com/iris-contrib/blackfriday"
"github.com/iris-contrib/schema"
jsoniter "github.com/json-iterator/go"
@@ -39,6 +38,7 @@ import (
"github.com/vmihailenco/msgpack/v5"
"golang.org/x/net/publicsuffix"
"golang.org/x/time/rate"
+ "google.golang.org/protobuf/proto"
"gopkg.in/yaml.v3"
)
@@ -1879,8 +1879,6 @@ func (ctx *context) FullRequestURI() string {
return ctx.AbsoluteURI(ctx.Path())
}
-const xForwardedForHeaderKey = "X-Forwarded-For"
-
// RemoteAddr tries to parse and return the real client's request IP.
//
// Based on allowed headers names that can be modified from Configuration.RemoteAddrHeaders.
@@ -2396,13 +2394,11 @@ func (ctx *context) URLParamBool(name string) (bool, error) {
// URLParams returns a map of GET query parameters separated by comma if more than one
// it returns an empty map if nothing found.
func (ctx *context) URLParams() map[string]string {
- values := map[string]string{}
-
q := ctx.request.URL.Query()
- if q != nil {
- for k, v := range q {
- values[k] = strings.Join(v, ",")
- }
+ values := make(map[string]string, len(q))
+
+ for k, v := range q {
+ values[k] = strings.Join(v, ",")
}
return values
@@ -4815,7 +4811,7 @@ func (rs *rateReadSeeker) Read(buf []byte) (int, error) {
if n <= 0 {
return n, err
}
- rs.limiter.WaitN(rs.ctx, n)
+ err = rs.limiter.WaitN(rs.ctx, n)
return n, err
}
diff --git a/context/response_recorder.go b/context/response_recorder.go
index 765bfea2..676ae58b 100644
--- a/context/response_recorder.go
+++ b/context/response_recorder.go
@@ -182,7 +182,12 @@ func (w *ResponseRecorder) Clone() ResponseWriter {
wc.headers = w.headers
wc.chunks = w.chunks[0:]
if resW, ok := w.ResponseWriter.(*responseWriter); ok {
- wc.ResponseWriter = &(*resW) // clone it
+ wc.ResponseWriter = &responseWriter{
+ ResponseWriter: resW.ResponseWriter,
+ statusCode: resW.statusCode,
+ written: resW.written,
+ beforeFlush: resW.beforeFlush,
+ } // clone it
} else { // else just copy, may pointer, developer can change its behavior
wc.ResponseWriter = w.ResponseWriter
}
diff --git a/core/handlerconv/from_std_test.go b/core/handlerconv/from_std_test.go
index 13d4142f..101b2d25 100644
--- a/core/handlerconv/from_std_test.go
+++ b/core/handlerconv/from_std_test.go
@@ -42,10 +42,11 @@ func TestFromStdWithNext(t *testing.T) {
basicauth := "secret"
passed := "ok"
+ type contextKey string
stdWNext := func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
if username, password, ok := r.BasicAuth(); ok &&
username == basicauth && password == basicauth {
- ctx := stdContext.WithValue(r.Context(), "key", "ok")
+ ctx := stdContext.WithValue(r.Context(), contextKey("key"), "ok")
next.ServeHTTP(w, r.WithContext(ctx))
return
}
@@ -54,7 +55,7 @@ func TestFromStdWithNext(t *testing.T) {
h := handlerconv.FromStdWithNext(stdWNext)
next := func(ctx context.Context) {
- ctx.WriteString(ctx.Request().Context().Value("key").(string))
+ ctx.WriteString(ctx.Request().Context().Value(contextKey("key")).(string))
}
app := iris.New()
diff --git a/core/host/proxy_test.go b/core/host/proxy_test.go
index 0aa056f6..78035ce6 100644
--- a/core/host/proxy_test.go
+++ b/core/host/proxy_test.go
@@ -60,7 +60,7 @@ func TestProxy(t *testing.T) {
t.Fatalf("%v while creating tcp4 listener for new tls local test listener", err)
}
// main server
- go app.Run(iris.Listener(httptest.NewLocalTLSListener(l)), iris.WithoutStartupLog)
+ go app.Run(iris.Listener(httptest.NewLocalTLSListener(l)), iris.WithoutStartupLog) // nolint:errcheck
e := httptest.NewInsecure(t, httptest.URL("http://"+listener.Addr().String()))
e.GET("/").Expect().Status(iris.StatusOK).Body().Equal(expectedIndex)
diff --git a/core/host/supervisor.go b/core/host/supervisor.go
index abf02e4f..96be33e5 100644
--- a/core/host/supervisor.go
+++ b/core/host/supervisor.go
@@ -395,7 +395,7 @@ func (su *Supervisor) runTLS(getCertificate func(*tls.ClientHelloInfo) (*tls.Cer
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
- tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
+ // tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, G402: TLS Bad Cipher Suite
0xC028, /* TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 */
},
}
diff --git a/core/router/handler.go b/core/router/handler.go
index 580f9210..ccf15cd4 100644
--- a/core/router/handler.go
+++ b/core/router/handler.go
@@ -128,7 +128,7 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
// before sort.
for _, r := range registeredRoutes {
if r.topLink != nil {
- bindMultiParamTypesHandler(r.topLink, r)
+ bindMultiParamTypesHandler(r)
}
}
@@ -279,7 +279,7 @@ func (h *routerHandler) Build(provider RoutesProvider) error {
return errgroup.Check(rp)
}
-func bindMultiParamTypesHandler(top *Route, r *Route) {
+func bindMultiParamTypesHandler(r *Route) {
r.BuildHandlers()
// println("here for top: " + top.Name + " and current route: " + r.Name)
diff --git a/core/router/status_test.go b/core/router/status_test.go
index 1b25bf36..12fee501 100644
--- a/core/router/status_test.go
+++ b/core/router/status_test.go
@@ -85,7 +85,7 @@ func TestOnAnyErrorCode(t *testing.T) {
func checkAndClearBuf(t *testing.T, buff *bytes.Buffer, expected string) {
t.Helper()
- if got, expected := buff.String(), expected; got != expected {
+ if got := buff.String(); got != expected {
t.Fatalf("expected middleware to run before the error handler, expected: '%s' but got: '%s'", expected, got)
}
diff --git a/go.mod b/go.mod
index 49f7f62e..f9e087f9 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,6 @@ require (
github.com/dgraph-io/badger/v2 v2.0.3
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385
github.com/fatih/structs v1.1.0
- github.com/golang/protobuf v1.4.2
github.com/gomodule/redigo v1.8.2
github.com/google/uuid v1.1.2-0.20200519141726-cb32006e483f
github.com/hashicorp/go-version v1.2.1
@@ -37,6 +36,7 @@ require (
golang.org/x/net v0.0.0-20200602114024-627f9648deb9
golang.org/x/text v0.3.3
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1
+ google.golang.org/protobuf v1.24.0
gopkg.in/ini.v1 v1.57.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
)
diff --git a/hero/binding_test.go b/hero/binding_test.go
index 475e1d0a..d9c5b932 100644
--- a/hero/binding_test.go
+++ b/hero/binding_test.go
@@ -343,7 +343,7 @@ func TestBindingsForStruct(t *testing.T) {
controller3 struct {
Emb1 embedded1
- emb2 embedded2
+ emb2 embedded2 // unused
}
)
diff --git a/hero/dependency.go b/hero/dependency.go
index 073c9718..509d6f95 100644
--- a/hero/dependency.go
+++ b/hero/dependency.go
@@ -87,7 +87,7 @@ func resolveDependency(v reflect.Value, dest *Dependency, funcDependencies ...*D
len(funcDependencies) > 0 && fromDependentFunc(v, dest, funcDependencies)
}
-func fromDependencyHandler(v reflect.Value, dest *Dependency) bool {
+func fromDependencyHandler(_ reflect.Value, dest *Dependency) bool {
// It's already on the desired form, just return it.
dependency := dest.OriginalValue
handler, ok := dependency.(DependencyHandler)
diff --git a/hero/func_result.go b/hero/func_result.go
index bfcf4e2d..b6cc5bcf 100644
--- a/hero/func_result.go
+++ b/hero/func_result.go
@@ -4,10 +4,10 @@ import (
"reflect"
"strings"
- "github.com/golang/protobuf/proto"
"github.com/kataras/iris/v12/context"
"github.com/fatih/structs"
+ "google.golang.org/protobuf/proto"
)
// ResultHandler describes the function type which should serve the "v" struct value.
diff --git a/hero/reflect.go b/hero/reflect.go
index 8b74f09b..1662afe3 100644
--- a/hero/reflect.go
+++ b/hero/reflect.go
@@ -15,15 +15,6 @@ func valueOf(v interface{}) reflect.Value {
return reflect.ValueOf(v)
}
-func typeOf(typ interface{}) reflect.Type {
- if v, ok := typ.(reflect.Type); ok {
- // check if it's already a reflect.Type.
- return v
- }
-
- return reflect.TypeOf(typ)
-}
-
// indirectType returns the value of a pointer-type "typ".
// If "typ" is a pointer, array, chan, map or slice it returns its Elem,
// otherwise returns the typ as it's.
diff --git a/iris.go b/iris.go
index 339fafa7..e8ffa9e9 100644
--- a/iris.go
+++ b/iris.go
@@ -1198,7 +1198,7 @@ func (app *Application) tryInjectLiveReload() error {
rec.SetBody(body)
} else {
// Just append it.
- rec.Write(scriptReloadJS)
+ rec.Write(scriptReloadJS) // nolint:errcheck
}
if _, has := rec.Header()[context.ContentLengthHeaderKey]; has {
@@ -1245,7 +1245,7 @@ func (app *Application) tryStartTunneling() {
app.config.vhost = publicAddr[strings.Index(publicAddr, "://")+3:]
directLog := []byte(fmt.Sprintf("• Public Address: %s\n", publicAddr))
- app.logger.Printer.Write(directLog)
+ app.logger.Printer.Write(directLog) // nolint:errcheck
}
})
})
diff --git a/macro/interpreter/lexer/lexer.go b/macro/interpreter/lexer/lexer.go
index a2f84c31..76d91c4d 100644
--- a/macro/interpreter/lexer/lexer.go
+++ b/macro/interpreter/lexer/lexer.go
@@ -87,7 +87,7 @@ func (l *Lexer) NextToken() (t token.Token) {
if isLetter(l.ch) {
// letters
lit := l.readIdentifier()
- typ := token.LookupIdent(lit)
+ typ = token.LookupIdent(lit)
t = l.newToken(typ, lit)
return
}
diff --git a/macro/macro.go b/macro/macro.go
index 617cfc17..25c6df22 100644
--- a/macro/macro.go
+++ b/macro/macro.go
@@ -139,7 +139,7 @@ func convertBuilderFunc(fn interface{}) ParamFuncBuilder {
var (
val interface{}
- panicIfErr = func(err error) {
+ panicIfErr = func(i int, err error) {
if err != nil {
panic(fmt.Sprintf("on field index: %d: %v", i, err))
}
@@ -150,55 +150,55 @@ func convertBuilderFunc(fn interface{}) ParamFuncBuilder {
switch field.Kind() {
case reflect.Int:
v, err := strconv.Atoi(arg)
- panicIfErr(err)
+ panicIfErr(i, err)
val = v
case reflect.Int8:
v, err := strconv.ParseInt(arg, 10, 8)
- panicIfErr(err)
+ panicIfErr(i, err)
val = int8(v)
case reflect.Int16:
v, err := strconv.ParseInt(arg, 10, 16)
- panicIfErr(err)
+ panicIfErr(i, err)
val = int16(v)
case reflect.Int32:
v, err := strconv.ParseInt(arg, 10, 32)
- panicIfErr(err)
+ panicIfErr(i, err)
val = int32(v)
case reflect.Int64:
v, err := strconv.ParseInt(arg, 10, 64)
- panicIfErr(err)
+ panicIfErr(i, err)
val = v
case reflect.Uint:
v, err := strconv.ParseUint(arg, 10, strconv.IntSize)
- panicIfErr(err)
+ panicIfErr(i, err)
val = uint(v)
case reflect.Uint8:
v, err := strconv.ParseUint(arg, 10, 8)
- panicIfErr(err)
+ panicIfErr(i, err)
val = uint8(v)
case reflect.Uint16:
v, err := strconv.ParseUint(arg, 10, 16)
- panicIfErr(err)
+ panicIfErr(i, err)
val = uint16(v)
case reflect.Uint32:
v, err := strconv.ParseUint(arg, 10, 32)
- panicIfErr(err)
+ panicIfErr(i, err)
val = uint32(v)
case reflect.Uint64:
v, err := strconv.ParseUint(arg, 10, 64)
- panicIfErr(err)
+ panicIfErr(i, err)
val = v
case reflect.Float32:
v, err := strconv.ParseFloat(arg, 32)
- panicIfErr(err)
+ panicIfErr(i, err)
val = float32(v)
case reflect.Float64:
v, err := strconv.ParseFloat(arg, 64)
- panicIfErr(err)
+ panicIfErr(i, err)
val = v
case reflect.Bool:
v, err := strconv.ParseBool(arg)
- panicIfErr(err)
+ panicIfErr(i, err)
val = v
case reflect.Slice:
if len(arg) > 1 {
diff --git a/middleware/basicauth/basicauth.go b/middleware/basicauth/basicauth.go
index cf4af761..4a09e9d2 100644
--- a/middleware/basicauth/basicauth.go
+++ b/middleware/basicauth/basicauth.go
@@ -23,7 +23,7 @@ type (
logged bool
expires time.Time
}
- encodedUsers []encodedUser
+ encodedUsers []*encodedUser
basicAuthMiddleware struct {
config Config
@@ -75,7 +75,7 @@ func (b *basicAuthMiddleware) init() {
for k, v := range b.config.Users {
fullUser := k + ":" + v
header := "Basic " + base64.StdEncoding.EncodeToString([]byte(fullUser))
- b.auth = append(b.auth, encodedUser{HeaderValue: header, Username: k, logged: false, expires: DefaultExpireTime})
+ b.auth = append(b.auth, &encodedUser{HeaderValue: header, Username: k, logged: false, expires: DefaultExpireTime})
}
// set the auth realm header's value
@@ -85,20 +85,16 @@ func (b *basicAuthMiddleware) init() {
b.askHandlerEnabled = b.config.OnAsk != nil
}
-func (b *basicAuthMiddleware) findAuth(headerValue string) (auth *encodedUser, found bool) {
- if len(headerValue) == 0 {
- return
- }
-
- for _, user := range b.auth {
- if user.HeaderValue == headerValue {
- auth = &user
- found = true
- break
+func (b *basicAuthMiddleware) findAuth(headerValue string) (*encodedUser, bool) {
+ if headerValue != "" {
+ for _, user := range b.auth {
+ if user.HeaderValue == headerValue {
+ return user, true
+ }
}
}
- return
+ return nil, false
}
func (b *basicAuthMiddleware) askForCredentials(ctx context.Context) {
diff --git a/middleware/jwt/rsa_util.go b/middleware/jwt/rsa_util.go
index e68b19f8..f40f69ab 100644
--- a/middleware/jwt/rsa_util.go
+++ b/middleware/jwt/rsa_util.go
@@ -41,7 +41,7 @@ func exportToFile(key *rsa.PrivateKey, filename string) error {
},
)
- return ioutil.WriteFile(filename, encoded, 0644)
+ return ioutil.WriteFile(filename, encoded, 0600)
}
func importFromFile(filename string) (*rsa.PrivateKey, error) {