Skip to content

Commit

Permalink
feat: update go to 1.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
CatchZeng committed Jun 16, 2021
1 parent 3c4e542 commit da0ebdc
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 43 deletions.
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
SHELL := /bin/bash
BASEDIR = $(shell pwd)

export GO111MODULE=on

APP_NAME=dingtalk
APP_VERSION=1.2.0
APP_VERSION=1.2.1
IMAGE_NAME="catchzeng/${APP_NAME}:${APP_VERSION}"
IMAGE_LATEST="catchzeng/${APP_NAME}:latest"

all: fmt
echo 'make all'
all: mod fmt imports lint test
first:
go get golang.org/x/tools/cmd/goimports
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.39.0
fmt:
gofmt -w .
mod:
go mod tidy
imports:
goimports -w .
lint:
golangci-lint run
.PHONY: test
Expand All @@ -26,34 +28,41 @@ build:
rm dingtalk
go build -o dingtalk cmd/main.go
build-mac:
rm -f dingtalk dingtalk-darwin-amd64.zip
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o dingtalk cmd/main.go
zip dingtalk-darwin-amd64.zip dingtalk
build-linux:
rm -f dingtalk dingtalk-linux-amd64.zip
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dingtalk cmd/main.go
zip dingtalk-linux-amd64.zip dingtalk
build-win:
rm -f dingtalk.exe dingtalk-windows-amd64.zip
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dingtalk.exe cmd/main.go
zip dingtalk-windows-amd64.zip dingtalk.exe
build-win32:
rm -f dingtalk.exe dingtalk-windows-386.zip
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -o dingtalk.exe cmd/main.go
zip dingtalk-windows-386.zip dingtalk.exe
build-release:
make build-mac
make build-linux
make build-win
make build-win32
rm -f dingtalk dingtalk.exe
build-docker:
echo ${IMAGE_NAME}
sh build/package/build.sh ${IMAGE_NAME}
push-docker: build-docker
docker tag ${IMAGE_NAME} ${IMAGE_LATEST};
docker push ${IMAGE_NAME};
docker push ${IMAGE_LATEST};
help:
@echo "first - first time"
@echo "fmt - go format"
@echo "mod - go mod tidy"
@echo "imports - go imports"
@echo "lint - run golangci-lint"
@echo "test - unit test"
@echo "mock - mockgen"
@echo "build - build binary"
@echo "build-mac - build mac binary"
@echo "build-linux - build linux amd64 binary"
Expand Down
6 changes: 1 addition & 5 deletions build/package/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
FROM golang:1.13.1-alpine as builder
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
ENV GOSUMDB=off
FROM golang:1.16.4-alpine as builder
RUN mkdir /build
ADD . /build/
WORKDIR /build
Expand All @@ -12,4 +9,3 @@ FROM alpine:3.7

COPY --from=builder /build/dingtalk /usr/local/bin/dingtalk
RUN chmod +x /usr/local/bin/dingtalk
RUN dingtalk version
5 changes: 3 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package dingtalk

import (
"bou.ke/monkey"
"errors"
"github.com/CatchZeng/dingtalk/internal/security"
"io"
"net/http"
"reflect"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk/internal/security"

mock_message "github.com/CatchZeng/dingtalk/test/mocks/message"
"github.com/golang/mock/gomock"
)
Expand Down
7 changes: 4 additions & 3 deletions cmd/dingtalk/actionCard_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package dingtalk

import (
"bou.ke/monkey"
"bytes"
"errors"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
"log"
"os"
"strings"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
)

func Test_runActionCardCmd(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/dingtalk/feedCard_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package dingtalk

import (
"bou.ke/monkey"
"bytes"
"errors"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
"log"
"os"
"strings"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
)

func Test_runFeedCardCmd(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/dingtalk/link_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package dingtalk

import (
"bou.ke/monkey"
"bytes"
"errors"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
"log"
"os"
"strings"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
)

func Test_runLinkCmd(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/dingtalk/markdown_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package dingtalk

import (
"bou.ke/monkey"
"bytes"
"errors"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
"log"
"os"
"strings"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
)

func Test_runMarkdownCmd(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/dingtalk/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package dingtalk
import (
"errors"
"fmt"
"log"
"os"

"github.com/CatchZeng/dingtalk"
"github.com/CatchZeng/dingtalk/configs"
"github.com/spf13/viper"
"log"
"os"

"github.com/spf13/cobra"
)
Expand Down
5 changes: 3 additions & 2 deletions cmd/dingtalk/root_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package dingtalk

import (
"bou.ke/monkey"
"errors"
"github.com/CatchZeng/dingtalk/configs"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk/configs"
)

func Test_newClient(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/dingtalk/text_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package dingtalk

import (
"bou.ke/monkey"
"bytes"
"errors"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
"log"
"os"
"strings"
"testing"

"bou.ke/monkey"
"github.com/CatchZeng/dingtalk"
"github.com/spf13/cobra"
)

func Test_runTextCmd(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/dingtalk/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

const (
version = "1.2.0"
buildTime = "2020/09/15"
version = "1.2.1"
buildTime = "2021/06/16"
)

// versionCmd represents the version command
Expand Down
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package main

import (
"github.com/CatchZeng/dingtalk/cmd/dingtalk"
"log"

"github.com/CatchZeng/dingtalk/cmd/dingtalk"
)

func main() {
Expand Down
6 changes: 3 additions & 3 deletions configs/configs.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package configs

import (
"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
"log"
"path"

"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
)

// InitConfig reads in configs file and ENV variables if set.
Expand All @@ -24,7 +25,6 @@ func InitConfig() {

// If a configs file is found, read it in.
if err := viper.ReadInConfig(); err != nil {
log.Printf("failed to read config file: %v", err)
return
}
log.Println("using configs file:", viper.ConfigFileUsed())
Expand Down
5 changes: 3 additions & 2 deletions configs/configs_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package configs

import (
"bou.ke/monkey"
"errors"
"testing"

"bou.ke/monkey"
"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
"testing"
)

func TestInitConfig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/CatchZeng/dingtalk

go 1.13
go 1.16

require (
bou.ke/monkey v1.0.2
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
3 changes: 2 additions & 1 deletion test/mocks/message/message.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da0ebdc

Please sign in to comment.