Skip to content

Commit

Permalink
[AUTOPR] Automatic updates (#217)
Browse files Browse the repository at this point in the history
* Update all dependencies, including golangci-lint.

* Simplify quick start docs for developers.

* Fix wsl and other minor linter errors.

* Fix perfsprint linter errors.

* Fix revive linter errors.

---------

Co-authored-by: nicolaasuni-vonage <[email protected]>
  • Loading branch information
github-actions[bot] and nicolaasuni-vonage authored Feb 20, 2024
1 parent ba7bee1 commit 20b25a9
Show file tree
Hide file tree
Showing 97 changed files with 490 additions and 425 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ issues:
linters:
- dupl
- funlen
#fix: true
# fix: true

linters:
enable:
Expand Down Expand Up @@ -136,6 +136,8 @@ linters:
- reassign # Checks that package variables are not reassigned [fast: false, auto-fix: false]
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
- sloglint # Detects the wrong usage of `slog` that a user forgets to dispatch with `Send` or `Msg`. [fast: false, auto-fix: false]
- spancheck # spancheck is a linter that detects the usage of context.Context.Value method. [fast: false, auto-fix: false]
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
- staticcheck # (megacheck): It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ GOFMT=$(shell which gofmt)
GOTEST=GOPATH=$(GOPATH) $(shell which gotest)
GODOC=GOPATH=$(GOPATH) $(shell which godoc)
GOLANGCILINT=$(BINUTIL)/golangci-lint
GOLANGCILINTVERSION=v1.55.2
GOLANGCILINTVERSION=v1.56.2

# Directory containing the source code
SRCDIR=./pkg
Expand Down Expand Up @@ -147,7 +147,7 @@ dbuild: dockerdev
# Get the test dependencies
.PHONY: deps
deps: ensuretarget
curl --silent --show-error --fail --location https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BINUTIL) $(GOLANGCILINTVERSION)
curl --silent --show-error --fail --location "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b $(BINUTIL) $(GOLANGCILINTVERSION)
$(GO) install github.com/rakyll/gotest
$(GO) install github.com/jstemmer/go-junit-report
$(GO) install github.com/golang/mock/mockgen
Expand Down
62 changes: 17 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

*Go Service Library*

This Open Source project contains a collection of high-quality GO (golang) packages.
This Open Source project contains a collection of high-quality [GO](https://go.dev/) (golang) packages.

The packages documentation is available at: [https://pkg.go.dev/github.com/Vonage/gosrvlib](https://pkg.go.dev/github.com/Vonage/gosrvlib)
Each package follows common conventions and they can be individually imported in any project.

This package collection forms the base structure for production-ready web-services.
This package collection forms the base structure for fully-fledged production-ready web-services.

A new service can be generated by using the command `make project CONFIG=project.cfg`.
A new Web service can be generated by using the command `make project CONFIG=project.cfg`.
The new generated project name, description, etc..., can be set in the file specified via the CONFIG parameter.

Each package follows the same conventions and they can be individually imported in any project.
The packages documentation is available at: [https://pkg.go.dev/github.com/Vonage/gosrvlib/](https://pkg.go.dev/github.com/Vonage/gosrvlib)

[![Go Reference](https://pkg.go.dev/badge/github.com/Vonage/gosrvlib.svg)](https://pkg.go.dev/github.com/Vonage/gosrvlib)
[![check](https://github.com/Vonage/gosrvlib/actions/workflows/check.yaml/badge.svg)](https://github.com/Vonage/gosrvlib/actions/workflows/check.yaml)
Expand Down Expand Up @@ -48,54 +48,26 @@ Each package follows the same conventions and they can be individually imported
-----------------------------------------------------------------

<a name="quickstart"></a>
## Quick Start
## Developers' Quick Start

This project includes a *Makefile* that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this *Makefile* are stored in the *target* folder.

All the packages listed in the *resources/docker/Dockerfile.dev* file are required in order to build and test all the library options in the current environment.
Alternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command "make dbuild".

To see all available options:
```bash
make help
```

To build the project inside a Docker container (requires Docker):
```bash
make dbuild
```

An arbitrary make target can be executed inside a Docker container by specifying the "MAKETARGET" parameter:
```bash
MAKETARGET='deps mod qa example' make dbuild
```
The list of make targets can be obtained by typing ```make```
To quickly get started with this project, follow these steps:

1. Ensure you ahev installed the latest Go version and Python3 for some extra tests.
1. Clone the repository: `git clone https://github.com/Vonage/gosrvlib.git`.
2. Change into the project directory: `cd gosrvlib`.
3. Install the required dependencies and test everything: `DEVMODE=LOCAL make x`.

The base Docker building environment is defined in the following Dockerfile:
```bash
resources/docker/Dockerfile.dev
```
Now you are ready to start developing with gosrvlib!

To download all dependencies:
```bash
make deps
```

To update the mod file:
```bash
make mod
```
This project includes a *Makefile* that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this *Makefile* are stored in the *target* folder.

To execute all the default test builds and generate reports in the current environment:
```bash
make qa
```
Alternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command `make dbuild` that uses the environment defined at `*`resources/docker/Dockerfile.dev`.

To format the code (please use this command before submitting any pull request):
To see all available options:
```bash
make format
make help
```

-----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.81.1
1.81.2
2 changes: 2 additions & 0 deletions examples/service/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ linters:
- reassign # Checks that package variables are not reassigned [fast: false, auto-fix: false]
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
- sloglint # Detects the wrong usage of `slog` that a user forgets to dispatch with `Send` or `Msg`. [fast: false, auto-fix: false]
- spancheck # spancheck is a linter that detects the usage of context.Context.Value method [fast: false, auto-fix: false]
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
- staticcheck # (megacheck): It's a set of rules from staticcheck. It's not the same thing as the staticcheck binary. The author of staticcheck doesn't support or approve the use of staticcheck as a library inside golangci-lint. [fast: false, auto-fix: false]
- stylecheck # Stylecheck is a replacement for golint [fast: false, auto-fix: false]
Expand Down
4 changes: 2 additions & 2 deletions examples/service/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ GOFMT=$(shell which gofmt)
GOTEST=GOPATH=$(GOPATH) $(shell which gotest)
GODOC=GOPATH=$(GOPATH) $(shell which godoc)
GOLANGCILINT=$(BINUTIL)/golangci-lint
GOLANGCILINTVERSION=v1.55.2
GOLANGCILINTVERSION=v1.56.2

# Current operating system and architecture as one string.
GOOSARCH=$(shell go env GOOS GOARCH | tr -d \\n)
Expand Down Expand Up @@ -397,7 +397,7 @@ endif
# Get the test dependencies
.PHONY: deps
deps: ensuretarget
curl --silent --show-error --fail --location https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BINUTIL) $(GOLANGCILINTVERSION)
curl --silent --show-error --fail --location "https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh" | sh -s -- -b $(BINUTIL) $(GOLANGCILINTVERSION)
$(GO) install github.com/mikefarah/yq/v4@latest
$(GO) install github.com/hairyhenderson/gomplate/v3/cmd/gomplate@latest
$(GO) install github.com/rakyll/gotest
Expand Down
41 changes: 12 additions & 29 deletions examples/service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,43 +89,26 @@ sudo pip install --upgrade check-jsonschema


<a name="quickstart"></a>
## Quick Start
## Developers' Quick Start

This project includes a Makefile that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this Makefile are stored in the *target* folder.
To quickly get started with this project, follow these steps:

All the packages listed in the *resources/docker/Dockerfile.dev* file are required in order to build and test all the library options in the current environment.
Alternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command "make dbuild".
1. Ensure you ahev installed the latest Go version and Python3 for some extra tests.
1. Clone the repository: `git clone https://github.com/gosrvlibexampleowner/gosrvlibexample.git`.
2. Change into the project directory: `cd gosrvlibexample`.
3. Install the required dependencies and test everything: `DEVMODE=LOCAL make x`.

To see all available options:
```bash
make help
```


To download all dependencies:
```bash
make deps
```
Now you are ready to start developing with /gosrvlibexample!

To update the mod file:
```bash
make mod
```

To format the code (please use this command before submitting any pull request):
```bash
make format
```
This project includes a *Makefile* that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this *Makefile* are stored in the *target* folder.

To execute all the default test builds and generate reports in the current environment:
```bash
make qa
```
Alternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command `make dbuild` that uses the environment defined at `resources/docker/Dockerfile.dev`.

To build the executable file:
To see all available options:
```bash
make build
make help
```


Expand Down
41 changes: 12 additions & 29 deletions examples/service/doc/src/development.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,26 @@ sudo pip install --upgrade check-jsonschema


<a name="quickstart"></a>
## Quick Start
## Developers' Quick Start

This project includes a Makefile that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this Makefile are stored in the *target* folder.
To quickly get started with this project, follow these steps:

All the packages listed in the *resources/docker/Dockerfile.dev* file are required in order to build and test all the library options in the current environment.
Alternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command "make dbuild".
1. Ensure you ahev installed the latest Go version and Python3 for some extra tests.
1. Clone the repository: `git clone https://github.com/gosrvlibexampleowner/gosrvlibexample.git`.
2. Change into the project directory: `cd gosrvlibexample`.
3. Install the required dependencies and test everything: `DEVMODE=LOCAL make x`.

To see all available options:
```bash
make help
```


To download all dependencies:
```bash
make deps
```
Now you are ready to start developing with /gosrvlibexample!

To update the mod file:
```bash
make mod
```

To format the code (please use this command before submitting any pull request):
```bash
make format
```
This project includes a *Makefile* that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this *Makefile* are stored in the *target* folder.

To execute all the default test builds and generate reports in the current environment:
```bash
make qa
```
Alternatively, everything can be built inside a [Docker](https://www.docker.com) container using the command `make dbuild` that uses the environment defined at `resources/docker/Dockerfile.dev`.

To build the executable file:
To see all available options:
```bash
make build
make help
```


Expand Down
2 changes: 1 addition & 1 deletion examples/service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
replace github.com/Vonage/gosrvlib => ../..

require (
github.com/Vonage/gosrvlib v1.81.1
github.com/Vonage/gosrvlib v1.81.2
github.com/golang/mock v1.6.0
github.com/jstemmer/go-junit-report v0.9.1
github.com/prometheus/client_golang v1.18.0
Expand Down
4 changes: 2 additions & 2 deletions examples/service/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.0 h1:SHN/umDLT
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.0/go.mod h1:l8gPU5RYGOFHJqWEpPMoRTP0VoaWQSkJdKo+hwWnnDA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.0 h1:l5puwOHr7IxECuPMIuZG7UKOzAnF24v6t4l+Z5Moay4=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.0/go.mod h1:Oov79flWa/n7Ni+lQC3z+VM7PoRM47omRqbJU9B5Y7E=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.0 h1:jZAdMD1ioZdqirzzVVRhpHHWJmcGGCn8JqDYBs5nmYA=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.0/go.mod h1:1o/W6JFUuREj2ExoQ21vHJgO7wakvjhol91M9eknFgs=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.1 h1:bjpWJEXch7moIt3PX2r5XpGROsletl7enqG1Q3Te1Dc=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.1/go.mod h1:1o/W6JFUuREj2ExoQ21vHJgO7wakvjhol91M9eknFgs=
github.com/aws/aws-sdk-go-v2/service/sqs v1.30.1 h1:YgHEUU4euy2VOUAzu08QSjtRwJLa9Nr1MD8qoW/b9RY=
github.com/aws/aws-sdk-go-v2/service/sqs v1.30.1/go.mod h1:4phHwV34rLb+56VjTud2w7hBu5Q57YIKFIA8Httzljg=
github.com/aws/aws-sdk-go-v2/service/sso v1.19.0 h1:u6OkVDxtBPnxPkZ9/63ynEe+8kHbtS5IfaC4PzVxzWM=
Expand Down
2 changes: 1 addition & 1 deletion examples/service/internal/cli/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

// bind is the entry point of the service, this is where the wiring of all components happens.
func bind(cfg *appConfig, appInfo *jsendx.AppInfo, mtr instr.Metrics, wg *sync.WaitGroup, sc chan struct{}) bootstrap.BindFunc {
return func(ctx context.Context, l *zap.Logger, m metrics.Client) error {
return func(ctx context.Context, _ *zap.Logger, m metrics.Client) error {
// We assume the service is disabled and override the service binder if required
serviceBinder := httpserver.NopBinder()
statusHandler := jsendx.DefaultStatusHandler(appInfo)
Expand Down
3 changes: 3 additions & 0 deletions examples/service/internal/cli/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func Test_bind(t *testing.T) {
if tt.preBindAddr != "" {
l, err := net.Listen("tcp", tt.preBindAddr)
require.NoError(t, err)

defer func() { _ = l.Close() }()
}

Expand Down Expand Up @@ -126,10 +127,12 @@ func Test_bind(t *testing.T) {
bootstrap.WithShutdownWaitGroup(wg),
bootstrap.WithShutdownSignalChan(sc),
}

err := bootstrap.Bootstrap(testBindFn, testBootstrapOpts...)
if tt.wantErr {
require.Error(t, err, "bind() error = %v, wantErr %v", err, tt.wantErr)
}

if tt.wantTimeoutErr {
require.ErrorIs(t, err, context.DeadlineExceeded,
"bind() error = %v, wantErr %v", err, context.DeadlineExceeded)
Expand Down
2 changes: 1 addition & 1 deletion examples/service/internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func New(version, release string, bootstrapFn bootstrapFunc) (*cobra.Command, er
versionCmd := &cobra.Command{
Use: "version",
Short: "Print this program version",
Run: func(cmd *cobra.Command, args []string) {
Run: func(_ *cobra.Command, _ []string) {
fmt.Println(version) //nolint:forbidigo
},
}
Expand Down
4 changes: 3 additions & 1 deletion examples/service/internal/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestNew(t *testing.T) {
{
name: "bootstrap with valid configuration",
osArgs: []string{AppName, "-c", "../../resources/test/etc/gosrvlibexample/"},
boostrapFunc: func(bindFn bootstrap.BindFunc, opts ...bootstrap.Option) error {
boostrapFunc: func(_ bootstrap.BindFunc, _ ...bootstrap.Option) error {
return nil
},
wantErr: false,
Expand All @@ -92,6 +92,7 @@ func TestNew(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
oldOsArgs := os.Args
defer func() { os.Args = oldOsArgs }()

os.Args = tt.osArgs

bootstrapFunc := bootstrap.Bootstrap
Expand All @@ -101,6 +102,7 @@ func TestNew(t *testing.T) {

// execute the main function
var out string

cmd, err := New("0.0.0-test", "0", bootstrapFunc)
if err == nil {
require.NotNil(t, cmd)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/aws/aws-sdk-go-v2 v1.25.0
github.com/aws/aws-sdk-go-v2/config v1.27.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.0
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.1
github.com/aws/aws-sdk-go-v2/service/sqs v1.30.1
github.com/confluentinc/confluent-kafka-go v1.9.2
github.com/dlmiddlecote/sqlstats v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.0 h1:SHN/umDLT
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.0/go.mod h1:l8gPU5RYGOFHJqWEpPMoRTP0VoaWQSkJdKo+hwWnnDA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.0 h1:l5puwOHr7IxECuPMIuZG7UKOzAnF24v6t4l+Z5Moay4=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.0/go.mod h1:Oov79flWa/n7Ni+lQC3z+VM7PoRM47omRqbJU9B5Y7E=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.0 h1:jZAdMD1ioZdqirzzVVRhpHHWJmcGGCn8JqDYBs5nmYA=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.0/go.mod h1:1o/W6JFUuREj2ExoQ21vHJgO7wakvjhol91M9eknFgs=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.1 h1:bjpWJEXch7moIt3PX2r5XpGROsletl7enqG1Q3Te1Dc=
github.com/aws/aws-sdk-go-v2/service/s3 v1.50.1/go.mod h1:1o/W6JFUuREj2ExoQ21vHJgO7wakvjhol91M9eknFgs=
github.com/aws/aws-sdk-go-v2/service/sqs v1.30.1 h1:YgHEUU4euy2VOUAzu08QSjtRwJLa9Nr1MD8qoW/b9RY=
github.com/aws/aws-sdk-go-v2/service/sqs v1.30.1/go.mod h1:4phHwV34rLb+56VjTud2w7hBu5Q57YIKFIA8Httzljg=
github.com/aws/aws-sdk-go-v2/service/sso v1.19.0 h1:u6OkVDxtBPnxPkZ9/63ynEe+8kHbtS5IfaC4PzVxzWM=
Expand Down
2 changes: 0 additions & 2 deletions pkg/awsopt/awsopt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/stretchr/testify/require"
)

//nolint:paralleltest
func Test_LoadDefaultConfig(t *testing.T) {
region := "us-west-2"

Expand Down Expand Up @@ -62,7 +61,6 @@ func Test_WithRegion(t *testing.T) {
}
}

//nolint:paralleltest
func Test_WithRegionFromURL(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading

0 comments on commit 20b25a9

Please sign in to comment.