diff --git a/.golangci.yml b/.golangci.yml index 3d40376e..307c1af6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,6 +8,24 @@ linters: - nolintlint - revive - staticcheck + - asasalint + - bodyclose + - contextcheck + - cyclop + - dupword + - errname + - exhaustive + - loggercheck + - misspell + - nestif + - perfsprint + - prealloc + - predeclared + - testifylint + - testpackage + - unconvert + - usestdlibvars + - wsl linters-settings: govet: @@ -17,3 +35,9 @@ linters-settings: - reflectvaluecompare - sortslice - unusedwrite + - defers + - atomic + - nilfunc + - printf + - sortslice + - tests diff --git a/Makefile b/Makefile index af0a64ac..4c29c824 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,6 @@ lint: install-checkers ## Lint the source code static-checks: install-checkers ## Static Analysis @echo "๐Ÿงน GoCI Lint.." @golangci-lint run ./... - @echo "๐Ÿงน Nilaway.." vuln: install-checkers ## Check for vulnerabilities @echo "๐Ÿ” Checking for vulnerabilities" diff --git a/pkg/api/http/server.go b/pkg/api/http/server.go index 6db53efb..4cc3765b 100644 --- a/pkg/api/http/server.go +++ b/pkg/api/http/server.go @@ -48,5 +48,5 @@ func (srv *Server) Shutdown(_ context.Context) error { ctx, cancel := context.WithTimeout(context.Background(), exitWaitTime) defer cancel() - return srv.server.Shutdown(ctx) + return srv.server.Shutdown(ctx) //nolint:contextcheck } diff --git a/pkg/buildAPIRequest.go b/pkg/buildAPIRequest.go index 0081074b..e8f280e8 100644 --- a/pkg/buildAPIRequest.go +++ b/pkg/buildAPIRequest.go @@ -26,8 +26,8 @@ var validate *validator.Validate = validator.New() func BuildAPIRequest(provider string, params map[string]string, mode string) (interface{}, error) { // provider is the name of the provider, e.g. "openai", params is the map of parameters from the client, // mode is the mode of the provider, e.g. "chat", configList is the list of provider configurations - var providerConfig map[string]interface{} + if config, ok := configList[provider].(ProviderConfigs); ok { if modeConfig, ok := config[mode].(map[string]interface{}); ok { providerConfig = modeConfig diff --git a/pkg/gateway.go b/pkg/gateway.go index f8d801a3..bdaff15a 100644 --- a/pkg/gateway.go +++ b/pkg/gateway.go @@ -81,7 +81,7 @@ LOOP: case <-ctx.Done(): gw.telemetry.Logger.Info("context done, terminating process") // Call shutdown with background context as the passed in context has been canceled - return gw.shutdown(context.Background()) + return gw.shutdown(context.Background()) //nolint:contextcheck } } diff --git a/pkg/telemetry/logging.go b/pkg/telemetry/logging.go index cea041b5..fd7407cf 100644 --- a/pkg/telemetry/logging.go +++ b/pkg/telemetry/logging.go @@ -32,9 +32,12 @@ type LogConfig struct { func NewLogConfig() *LogConfig { return &LogConfig{ - Level: zap.NewAtomicLevelAt(zap.InfoLevel), - Encoding: "json", - OutputPaths: []string{"stdout"}, + Level: zap.NewAtomicLevelAt(zap.InfoLevel), + Encoding: "json", + DisableCaller: false, + DisableStacktrace: false, + OutputPaths: []string{"stdout"}, + InitialFields: make(map[string]interface{}), } } @@ -63,7 +66,6 @@ func NewHertzLogger(zapConfig *zap.Config) (*hertzzap.Logger, error) { // Both hertzzap and zap have a set of private methods that prevents from leveraging // their native encoder & sink building functionality // We had to copy & paste some of those to get it working - var encoder zapcore.Encoder if zapConfig.Encoding == "console" {