Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go 1.19 support and linter fixes #1975

Merged
merged 12 commits into from
Aug 18, 2022
4 changes: 2 additions & 2 deletions .github/workflows/certification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.18'
go-version: '^1.19'

- name: Download Go dependencies
working-directory: ${{ env.TEST_PATH }}
Expand All @@ -199,7 +199,7 @@ jobs:
- name: Check that go mod tidy is up-to-date
working-directory: ${{ env.TEST_PATH }}
run: |
go mod tidy -compat=1.18
go mod tidy -compat=1.19
git diff --exit-code ./go.mod
git diff --exit-code ./go.sum

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/components-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
GOVER: "1.18"
GOVER: "1.19"
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
GOLANGCI_LINT_VER: "v1.45.2"
GOLANGCI_LINT_VER: "v1.48.0"
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.18'
go-version: '^1.19'

- name: Download Go dependencies
run: |
Expand Down
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ linters:
- nestif
- nlreturn
- exhaustive
- exhaustruct
berndverst marked this conversation as resolved.
Show resolved Hide resolved
- noctx
- gci
- golint
Expand All @@ -259,7 +260,6 @@ linters:
- godot
- cyclop
- varnamelen
- gosec
- errorlint
- forcetypeassert
- ifshort
Expand All @@ -271,3 +271,8 @@ linters:
- wastedassign
- containedctx
- gosimple
- nonamedreturns
- asasalint
- rowserrcheck
- sqlclosecheck
- structcheck
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ MODFILES := $(shell find . -name go.mod)
define modtidy-target
.PHONY: modtidy-$(1)
modtidy-$(1):
cd $(shell dirname $(1)); go mod tidy -compat=1.18; cd -
cd $(shell dirname $(1)); go mod tidy -compat=1.19; cd -
endef

# Generate modtidy target action for each go.mod file
Expand Down
4 changes: 2 additions & 2 deletions bindings/alicloud/dingtalk/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type outgoingWebhook struct {
handler bindings.Handler
}

var webhooks = struct { //nolint: gochecknoglobals
var webhooks = struct { //nolint:gochecknoglobals
sync.RWMutex
m map[string]*outgoingWebhook
}{m: make(map[string]*outgoingWebhook)}
Expand Down Expand Up @@ -162,7 +162,7 @@ func (t *DingTalkWebhook) sendMessage(ctx context.Context, req *bindings.InvokeR
ctx, cancel := context.WithTimeout(ctx, defaultHTTPClientTimeout)
defer cancel()

httpReq, err := http.NewRequestWithContext(ctx, "POST", postURL, bytes.NewReader(msg))
httpReq, err := http.NewRequestWithContext(ctx, http.MethodPost, postURL, bytes.NewReader(msg))
if err != nil {
return fmt.Errorf("dingtalk webhook error: new request failed. %w", err)
}
Expand Down
24 changes: 12 additions & 12 deletions bindings/alicloud/dubbo/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
)

const (
metadataRpcGroup = "group"
metadataRpcVersion = "version"
metadataRpcInterface = "interfaceName"
metadataRpcMethodName = "methodName"
metadataRpcProviderHostname = "providerHostname"
metadataRpcProviderPort = "providerPort"
metadataRPCGroup = "group"
metadataRPCVersion = "version"
metadataRPCInterface = "interfaceName"
metadataRPCMethodName = "methodName"
metadataRPCProviderHostname = "providerHostname"
metadataRPCProviderPort = "providerPort"
)

type dubboContext struct {
Expand All @@ -47,12 +47,12 @@ type dubboContext struct {

func newDubboContext(metadata map[string]string) *dubboContext {
dubboMetadata := &dubboContext{}
dubboMetadata.group = metadata[metadataRpcGroup]
dubboMetadata.interfaceName = metadata[metadataRpcInterface]
dubboMetadata.version = metadata[metadataRpcVersion]
dubboMetadata.method = metadata[metadataRpcMethodName]
dubboMetadata.hostname = metadata[metadataRpcProviderHostname]
dubboMetadata.port = metadata[metadataRpcProviderPort]
dubboMetadata.group = metadata[metadataRPCGroup]
dubboMetadata.interfaceName = metadata[metadataRPCInterface]
dubboMetadata.version = metadata[metadataRPCVersion]
dubboMetadata.method = metadata[metadataRPCMethodName]
dubboMetadata.hostname = metadata[metadataRPCProviderHostname]
dubboMetadata.port = metadata[metadataRPCProviderPort]
dubboMetadata.inited = false
return dubboMetadata
}
Expand Down
8 changes: 4 additions & 4 deletions bindings/alicloud/dubbo/dubbo_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ func TestInvoke(t *testing.T) {
// 3. invoke dapr dubbo output binding, get rsp bytes
rsp, err := output.Invoke(context.Background(), &bindings.InvokeRequest{
Metadata: map[string]string{
metadataRpcProviderPort: dubboPort,
metadataRpcProviderHostname: localhostIP,
metadataRpcMethodName: methodName,
metadataRpcInterface: providerInterfaceName,
metadataRPCProviderPort: dubboPort,
metadataRPCProviderHostname: localhostIP,
metadataRPCMethodName: methodName,
metadataRPCInterface: providerInterfaceName,
},
Data: reqData,
Operation: bindings.GetOperation,
Expand Down
1 change: 1 addition & 0 deletions bindings/alicloud/dubbo/raw_data_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint:nosnakecase
package dubbo

import (
Expand Down
2 changes: 1 addition & 1 deletion bindings/alicloud/nacos/nacos.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Nacos struct {
watches []configParam
servers []constant.ServerConfig
logger logger.Logger
configClient config_client.IConfigClient
configClient config_client.IConfigClient //nolint:nosnakecase
readHandler func(ctx context.Context, response *bindings.ReadResponse) ([]byte, error)
}

Expand Down
2 changes: 1 addition & 1 deletion bindings/alicloud/nacos/nacos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func getNacosLocalCacheMetadata() (map[string]string, error) {
}

cfgFile := path.Join(tmpDir, fmt.Sprintf("%s@@%s@@", dataID, group))
file, err := os.OpenFile(cfgFile, os.O_RDWR|os.O_CREATE, os.ModePerm)
file, err := os.OpenFile(cfgFile, os.O_RDWR|os.O_CREATE, os.ModePerm) //nolint:nosnakecase
if err != nil || file == nil {
return nil, fmt.Errorf("open %s failed. %w", cfgFile, err)
}
Expand Down
6 changes: 3 additions & 3 deletions bindings/alicloud/tablestore/tablestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ func (s *AliCloudTableStore) create(req *bindings.InvokeRequest, resp *bindings.
TableName: s.getTableName(req.Metadata),
PrimaryKey: &tablestore.PrimaryKey{PrimaryKeys: pks},
Columns: columns,
ReturnType: tablestore.ReturnType_RT_NONE,
ReturnType: tablestore.ReturnType_RT_NONE, //nolint:nosnakecase
berndverst marked this conversation as resolved.
Show resolved Hide resolved
TransactionId: nil,
}

change.SetCondition(tablestore.RowExistenceExpectation_IGNORE)
change.SetCondition(tablestore.RowExistenceExpectation_IGNORE) //nolint:nosnakecase

putRequest := &tablestore.PutRowRequest{
PutRowChange: &change,
Expand Down Expand Up @@ -301,7 +301,7 @@ func (s *AliCloudTableStore) delete(req *bindings.InvokeRequest, resp *bindings.
TableName: s.getTableName(req.Metadata),
PrimaryKey: &tablestore.PrimaryKey{PrimaryKeys: pks},
}
change.SetCondition(tablestore.RowExistenceExpectation_IGNORE)
change.SetCondition(tablestore.RowExistenceExpectation_IGNORE) //nolint:nosnakecase
deleteReq := &tablestore.DeleteRowRequest{DeleteRowChange: change}
_, err = s.client.DeleteRow(deleteReq)

Expand Down
3 changes: 2 additions & 1 deletion bindings/apns/authorization_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func (a *authorizationBuilder) generateAuthorizationHeader() (string, error) {
a.logger.Debug("Authorization token expired; generating new token")

now := time.Now()
claims := jwt.StandardClaims{
// TODO: Use jwt.RegisteredClaims instead of jwt.StandardClaims.
claims := jwt.StandardClaims{ //nolint:staticcheck
IssuedAt: time.Now().Unix(),
Issuer: a.teamID,
}
Expand Down
118 changes: 59 additions & 59 deletions bindings/apns/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
// send push notifications to Apple devices and Mac computers using Apple's
// Push Notification Service (APNS).
//
// Configuring the Binding
// # Configuring the Binding
//
// To use the APNS output binding, you will need to create the binding
// configuration and add it to your components directory. The binding
Expand All @@ -31,37 +31,37 @@ limitations under the License.
//
// A sample configuration file for the APNS binding is shown below:
//
// apiVersion: dapr.io/v1alpha1
// kind: Component
// metadata:
// name: apns
// namespace: default
// spec:
// type: bindings.apns
// metadata:
// - name: development
// value: false
// - name: key-id
// value: PUT-KEY-ID-HERE
// - name: team-id
// value: PUT-APPLE-TEAM-ID-HERE
// - name: private-key
// secretKeyRef:
// name: apns-secrets
// key: private-key
// apiVersion: dapr.io/v1alpha1
// kind: Component
// metadata:
// name: apns
// namespace: default
// spec:
// type: bindings.apns
// metadata:
// - name: development
// value: false
// - name: key-id
// value: PUT-KEY-ID-HERE
// - name: team-id
// value: PUT-APPLE-TEAM-ID-HERE
// - name: private-key
// secretKeyRef:
// name: apns-secrets
// key: private-key
//
// If using Kubernetes, a sample secret configuration may look like this:
//
// apiVersion: v1
// kind: Secret
// metadata:
// name: apns-secrets
// namespace: default
// stringData:
// private-key: |
// -----BEGIN PRIVATE KEY-----
// KEY-DATA-GOES-HERE
// -----END PRIVATE KEY-----
// apiVersion: v1
// kind: Secret
// metadata:
// name: apns-secrets
// namespace: default
// stringData:
// private-key: |
// -----BEGIN PRIVATE KEY-----
// KEY-DATA-GOES-HERE
// -----END PRIVATE KEY-----
//
// The development parameter can be either "true" or "false". The development
// parameter controls which APNS service is used. If development is set to
Expand All @@ -70,7 +70,7 @@ limitations under the License.
// be used to send push notifications. If not specified, the production service
// will be chosen by default.
//
// Push Notification Format
// # Push Notification Format
//
// The APNS binding is a pass-through wrapper over the Apple Push Notification
// Service. The APNS binding will send the request directly to the APNS service
Expand All @@ -81,14 +81,14 @@ limitations under the License.
// Requests sent to the APNS binding should be a JSON object. A simple push
// notification appears below:
//
// {
// "aps": {
// "alert": {
// "title": "New Updates!",
// "body": "New updates are now available for your review."
// }
// }
// }
// {
// "aps": {
// "alert": {
// "title": "New Updates!",
// "body": "New updates are now available for your review."
// }
// }
// }
//
// The aps child object contains the push notification details that are used
// by the Apple Push Notification Service and target devices to route and show
Expand Down Expand Up @@ -124,27 +124,27 @@ limitations under the License.
// notifications from a chat room may have the same identifier causing them
// to show up together in the device's notifications list.
//
// Sending a Push Notification Using the APNS Binding
// # Sending a Push Notification Using the APNS Binding
//
// A simple request to the APNS binding looks like this:
//
// {
// "data": {
// "aps": {
// "alert": {
// "title": "New Updates!",
// "body": "New updates are available for your review."
// }
// }
// },
// "metadata": {
// "device-token": "PUT-DEVICE-TOKEN-HERE",
// "apns-push-type": "alert",
// "apns-priority": "10",
// "apns-topic": "com.example.helloworld"
// },
// "operation": "create"
// }
// {
// "data": {
// "aps": {
// "alert": {
// "title": "New Updates!",
// "body": "New updates are available for your review."
// }
// }
// },
// "metadata": {
// "device-token": "PUT-DEVICE-TOKEN-HERE",
// "apns-push-type": "alert",
// "apns-priority": "10",
// "apns-topic": "com.example.helloworld"
// },
// "operation": "create"
// }
//
// The device-token metadata field is required and should contain the token
// for the device that will receive the push notification. Only one device
Expand All @@ -158,9 +158,9 @@ limitations under the License.
// the apns-id metadata value, then the Apple Push Notification Serivce will
// generate a unique ID and will return it.
//
// {
// "messageID": "12345678-1234-1234-1234-1234567890AB"
// }
// {
// "messageID": "12345678-1234-1234-1234-1234567890AB"
// }
//
// If the push notification could not be sent due to an authentication error
// or payload error, the error code returned by Apple will be returned. For
Expand Down
4 changes: 2 additions & 2 deletions bindings/aws/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/mitchellh/mapstructure"

"github.com/dapr/components-contrib/bindings"
aws_auth "github.com/dapr/components-contrib/internal/authentication/aws"
awsAuth "github.com/dapr/components-contrib/internal/authentication/aws"
"github.com/dapr/kit/logger"
)

Expand Down Expand Up @@ -104,7 +104,7 @@ func (d *DynamoDB) getDynamoDBMetadata(spec bindings.Metadata) (*dynamoDBMetadat
}

func (d *DynamoDB) getClient(metadata *dynamoDBMetadata) (*dynamodb.DynamoDB, error) {
sess, err := aws_auth.GetClient(metadata.AccessKey, metadata.SecretKey, metadata.SessionToken, metadata.Region, metadata.Endpoint)
sess, err := awsAuth.GetClient(metadata.AccessKey, metadata.SecretKey, metadata.SessionToken, metadata.Region, metadata.Endpoint)
if err != nil {
return nil, err
}
Expand Down
Loading