Skip to content

Commit

Permalink
fix: linting issues (#2566)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochumdev authored Sep 30, 2022
1 parent 85c0b0b commit 010b1d9
Show file tree
Hide file tree
Showing 53 changed files with 401 additions and 296 deletions.
15 changes: 8 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@
name: Bug report
about: For reporting bugs in go-micro
title: "[BUG]"
labels: ''
assignees: ''

labels: ""
assignees: ""
---

**Describe the bug**
## Describe the bug

1. What are you trying to do?
2. What did you expect to happen?
3. What happens instead?

**How to reproduce the bug:**
## How to reproduce the bug

If possible, please include a minimal code snippet here.

**Environment:**
## Environment

Go Version: please paste `go version` output here
```

```go
please paste `go env` output here
```
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature-request---enhancement.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
name: Feature request / Enhancement
about: If you have a need not served by go-micro
title: "[FEATURE]"
labels: ''
assignees: ''

labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
---
name: Question
about: Ask a question about go-micro
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

Before asking, please check if your question has already been answered:
Before asking, please check if your question has already been answered:

1. Check the documentation - https://micro.mu/docs/
2. Check the examples and plugins - https://github.com/micro/examples & https://github.com/micro/go-plugins
Expand Down
7 changes: 4 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## Pull Request template
# Pull Request template

Please, go through these steps before clicking submit on this PR.

1. Make sure this PR targets the `develop` branch. We follow the git-flow branching model.
2. Give a descriptive title to your PR.
3. Provide a description of your changes.
3. Provide a description of your changes.
4. Make sure you have some relevant tests.
5. Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if applicable).

**PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING**
## PLEASE REMOVE THIS TEMPLATE BEFORE SUBMITTING
94 changes: 47 additions & 47 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
name: Run Tests
on:
on:
push:
branches:
- '**'
- "**"
pull_request:
types:
- opened
- reopened
types:
- opened
- reopened
branches:
- '**'
- "**"
jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
unittests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
cache: true
- name: Get dependencies
run: |
go install github.com/kyoh86/richgo@latest
go get -v -t -d ./...
- name: Run tests
id: tests
run: richgo test -v -race -cover ./...
env:
IN_TRAVIS_CI: yes
RICHGO_FORCE_COLOR: 1
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
cache: true
- name: Get dependencies
run: |
go install github.com/kyoh86/richgo@latest
go get -v -t -d ./...
- name: Run tests
id: tests
run: richgo test -v -race -cover ./...
env:
IN_TRAVIS_CI: yes
RICHGO_FORCE_COLOR: 1
summary:
name: Summary Report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
cache: true
- name: Get dependencies
run: |
go install github.com/mfridman/tparse@latest
go get -v -t -d ./...
- name: Run tests
id: tests
run: go test -v -race -cover -json ./... | tparse -notests -format=markdown >> $GITHUB_STEP_SUMMARY
env:
IN_TRAVIS_CI: yes
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true
cache: true
- name: Get dependencies
run: |
go install github.com/mfridman/tparse@latest
go get -v -t -d ./...
- name: Run tests
id: tests
run: go test -v -race -cover -json ./... | tparse -notests -format=markdown >> $GITHUB_STEP_SUMMARY
env:
IN_TRAVIS_CI: yes
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Develop tools
/.vscode/
/.idea/
/.trunk

# Binaries for programs and plugins
*.exe
Expand Down
14 changes: 12 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ run:
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files: []
skip-files:
[]
# - .*\\.pb\\.go$

allow-parallel-runners: true
Expand Down Expand Up @@ -186,7 +187,7 @@ linters:

# Can be considered to be enabled
- gochecknoinits
- gochecknoglobals # RIP
- gochecknoglobals # RIP
- dogsled
- wrapcheck
- paralleltest
Expand All @@ -210,6 +211,15 @@ issues:
# - path: internal/app/machined/pkg/system/services
# linters:
# - dupl
exclude-rules:
- path: _test\.go
linters:
- gocyclo
- dupl
- gosec
- funlen
- varnamelen
- wsl

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand Down
7 changes: 7 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*out
*logs
*actions
*notifications
plugins
user_trunk.yaml
user.yaml
10 changes: 10 additions & 0 deletions .trunk/config/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
28 changes: 28 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 0.1
actions:
enabled:
- trunk-announce
- trunk-cache-prune
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
runtimes:
enabled:
- go@1.18.3
- node@16.14.2
lint:
enabled:
- actionlint@1.6.20
- git-diff-check
- gitleaks@8.13.0
- gofmt@1.16.7
- golangci-lint@1.49.0
- markdownlint@0.32.2
- prettier@2.7.1
cli:
version: 0.18.1-beta
plugins:
sources:
- id: trunk
ref: v0.0.4
uri: https://github.com/trunk-io/plugins
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Go Micro [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Go.Dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/go-micro.dev/v4?tab=doc) [![Go Report Card](https://goreportcard.com/badge/github.com/go-micro/go-micro)](https://goreportcard.com/report/github.com/go-micro/go-micro) [![](https://dcbadge.vercel.app/api/server/qV3HvnEJfB?style=flat-square&theme=default-inverted)](https://discord.gg/qV3HvnEJfB)

# Go Micro [![License](https://img.shields.io/:license-apache-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Go.Dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/go-micro.dev/v4?tab=doc) [![Go Report Card](https://goreportcard.com/badge/github.com/go-micro/go-micro)](https://goreportcard.com/report/github.com/go-micro/go-micro) [![Discord](https://dcbadge.vercel.app/api/server/qV3HvnEJfB?style=flat-square&theme=default-inverted)](https://discord.gg/qV3HvnEJfB)

Go Micro is a framework for distributed systems development.

Expand Down
1 change: 0 additions & 1 deletion api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/gorilla/websocket"

"go-micro.dev/v4/logger"
)

Expand Down
2 changes: 0 additions & 2 deletions api/handler/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

jsonpatch "github.com/evanphx/json-patch/v5"
"github.com/oxtoacart/bpool"

"go-micro.dev/v4/api/handler"
"go-micro.dev/v4/api/internal/proto"
"go-micro.dev/v4/api/router"
Expand Down Expand Up @@ -458,7 +457,6 @@ func requestPayload(r *http.Request) ([]byte, error) {
return out, nil
}

//fallback to previous unknown behaviour
return bodybuf, nil
}

Expand Down
1 change: 0 additions & 1 deletion api/handler/rpc/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/gobwas/httphead"
"github.com/gobwas/ws"
"github.com/gobwas/ws/wsutil"

"go-micro.dev/v4/api/router"
"go-micro.dev/v4/client"
raw "go-micro.dev/v4/codec/bytes"
Expand Down
1 change: 0 additions & 1 deletion api/router/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,5 @@ func NewRouter(opts ...router.Option) *staticRouter {
eps: make(map[string]*endpoint),
}
// go r.watch()
//go r.refresh()
return r
}
3 changes: 1 addition & 2 deletions api/server/acme/autocert/autocert.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"net"
"os"

"golang.org/x/crypto/acme/autocert"

"go-micro.dev/v4/api/server/acme"
log "go-micro.dev/v4/logger"
"golang.org/x/crypto/acme/autocert"
)

// autoCertACME is the ACME provider from golang.org/x/crypto/acme/autocert.
Expand Down
1 change: 0 additions & 1 deletion api/server/acme/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package acme

import (
"github.com/go-acme/lego/v4/challenge"

"go-micro.dev/v4/logger"
)

Expand Down
1 change: 0 additions & 1 deletion api/server/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync"

"github.com/gorilla/handlers"

"go-micro.dev/v4/api/server"
"go-micro.dev/v4/api/server/cors"
log "go-micro.dev/v4/logger"
Expand Down
5 changes: 2 additions & 3 deletions api/server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"crypto/tls"
"net/http"

"go-micro.dev/v4/api/server/cors"
"go-micro.dev/v4/logger"

"go-micro.dev/v4/api/resolver"
"go-micro.dev/v4/api/server/acme"
"go-micro.dev/v4/api/server/cors"
"go-micro.dev/v4/logger"
)

type Option func(o *Options)
Expand Down
5 changes: 4 additions & 1 deletion broker/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Broker interface {
// message and optional Ack method to acknowledge receipt of the message.
type Handler func(Event) error

// Message is a message send/received from the broker.
type Message struct {
Header map[string]string
Body []byte
Expand All @@ -39,7 +40,8 @@ type Subscriber interface {
}

var (
DefaultBroker Broker = NewBroker()
// DefaultBroker is the default Broker.
DefaultBroker = NewBroker()
)

func Init(opts ...Option) error {
Expand All @@ -62,6 +64,7 @@ func Subscribe(topic string, handler Handler, opts ...SubscribeOption) (Subscrib
return DefaultBroker.Subscribe(topic, handler, opts...)
}

// String returns the name of the Broker.
func String() string {
return DefaultBroker.String()
}
Loading

0 comments on commit 010b1d9

Please sign in to comment.