Compare commits

...

10 Commits

Author SHA1 Message Date
liruichen_wsl
e780c3f2ed rm: test workflow
All checks were successful
Build Release / release linux/amd64 (release) Successful in 1m51s
Build Release / release linux/386 (release) Successful in 1m20s
Build Release / release darwin/amd64 (release) Successful in 59s
Build Release / release windows/amd64 (release) Successful in 1m4s
2024-11-19 16:24:36 +08:00
liruichen_wsl
49c91795c6 Merge branch 'qiniu-v2' 2024-11-19 12:35:52 +08:00
liruichen_wsl
c170be7a00 merge: qiniu 2024-11-19 12:34:49 +08:00
liruichen_wsl
24e06870bb refactor: go module name 2024-11-19 11:32:10 +08:00
Li Yiyang
7b466bc7b4
feat: register extra information during build (#390)
* feat: register extra information during build

* update github action go version

* update action
2024-11-15 15:22:22 +08:00
liruichen
f0fbcc680a feat: only inject cmd 2024-09-05 15:10:18 +08:00
liruichen_wsl
9c8503082e feat: update go version 1.22 amend 2024-08-21 16:27:46 +08:00
liruichen_wsl
eddd55fdb5 feat: update go version 1.22 2024-08-21 16:21:59 +08:00
Li Yiyang
ba7372a236
support new go.mod (#378) 2024-06-18 11:25:45 +08:00
liruichen_wsl
c85c491bc9 style: fmtBranch 2024-03-13 16:24:27 +08:00
42 changed files with 2613 additions and 2648 deletions

37
.github/e2e-linux.yml vendored
View File

@ -1,37 +0,0 @@
name: e2e test
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
paths-ignore:
- '**.md'
- '**.png'
pull_request:
paths-ignore:
- '**.md'
- '**.png'
jobs:
job_1:
name: e2e test
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Checkout code
uses: actions/checkout@v2
- name: Go build
run: |
go build .
go install .
- name: Use goc to build self
run: |
./goc build -o ./gocc .
- name: run e2e test
run: |
go get github.com/onsi/ginkgo/ginkgo
make e2e

37
.github/e2e-wins.yml vendored
View File

@ -1,37 +0,0 @@
name: e2e test
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
paths-ignore:
- '**.md'
- '**.png'
pull_request:
paths-ignore:
- '**.md'
- '**.png'
jobs:
job_1:
name: e2e test
strategy:
matrix:
os: [windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Checkout code
uses: actions/checkout@v2
- name: Go build
run: |
go build .
go install .
- name: Use goc to build self
run: |
.\goc.exe build -o gocc .
- name: run e2e test
run: |
go get github.com/onsi/ginkgo/ginkgo
ginkgo tests/e2e/...

View File

@ -1,39 +0,0 @@
name: style-check
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
paths-ignore:
- '**.md'
- '**.png'
pull_request:
paths-ignore:
- '**.md'
- '**.png'
jobs:
run:
name: vet and gofmt
strategy:
matrix:
go-version: [1.16.x]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
# This step checks out a copy of your repository.
- name: Checkout code
uses: actions/checkout@v2
- name: Go vet check
run: |
go vet ./...
- name: Gofmt check
run: |
diff=`find . -name "*.go" | xargs gofmt -s -d`
if [[ -n "${diff}" ]]; then
echo "Gofmt check failed :"
echo "${diff}"
echo "Please run this command to fix: [find . -name "*.go" | xargs gofmt -s -w]"
exit 1
fi

View File

@ -1,32 +0,0 @@
name: unit test
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
paths-ignore:
- '**.md'
- '**.png'
pull_request:
paths-ignore:
- '**.md'
- '**.png'
jobs:
run:
name: go test on windows
strategy:
matrix:
go-version: [1.16.x]
runs-on: windows-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
# This step checks out a copy of your repository.
- name: Checkout code
uses: actions/checkout@v2
- name: Go test
env:
GOVERSION: ${{ matrix.go-version }}
run: |
go test -p 1 .\pkg\...

33
.github/ut-check.yml vendored
View File

@ -1,33 +0,0 @@
name: unit test
on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
paths-ignore:
- '**.md'
- '**.png'
pull_request:
paths-ignore:
- '**.md'
- '**.png'
jobs:
run:
name: go test on linux
strategy:
matrix:
go-version: [1.16.x]
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
# This step checks out a copy of your repository.
- name: Checkout code
uses: actions/checkout@v2
- name: Go test
env:
GOVERSION: ${{ matrix.go-version }}
run: |
make test
bash <(curl -s https://codecov.io/bash) -F unittest-$GOVERSION

View File

@ -12,7 +12,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.22.x
- name: compile and release
run: |
./hack/release.sh
@ -30,7 +30,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.22.x
- name: compile and release
run: |
./hack/release.sh
@ -48,7 +48,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.19.x
go-version: 1.22.x
- name: compile and release
run: |
./hack/release.sh
@ -57,19 +57,19 @@ jobs:
GOARCH: amd64
GOOS: darwin
# release-windows-amd64:
# name: release windows/amd64
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@master
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.19.x
# - name: compile and release
# run: |
# ./hack/release.sh
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GOARCH: amd64
# GOOS: windows
release-windows-amd64:
name: release windows/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.22.x
- name: compile and release
run: |
./hack/release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOARCH: amd64
GOOS: windows

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
tests/e2e/tmp/*
.goc.kvstore
coverage.txt
.idea
repos

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/build"
"github.com/ar0c/goc/v2/pkg/build"
"github.com/spf13/cobra"
)
@ -28,11 +28,13 @@ var buildCmd = &cobra.Command{
var (
gocmode string
gochost string
gocextra string
)
func init() {
buildCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
buildCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
buildCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build")
rootCmd.AddCommand(buildCmd)
}
@ -47,6 +49,7 @@ func buildAction(cmd *cobra.Command, args []string) {
build.WithArgs(args),
build.WithBuild(),
build.WithDebug(globalDebug),
build.WithExtra(gocextra),
)
b.Build()

44
cmd/inject.go Normal file
View File

@ -0,0 +1,44 @@
/*
Copyright 2021 Qiniu Cloud (qiniu.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"github.com/ar0c/goc/v2/pkg/build"
"github.com/spf13/cobra"
)
var injectCmd = &cobra.Command{
Use: "inject",
Run: injectAction,
//DisableFlagParsing: true, // build 命令需要用原生 go 的方式处理 flags
}
func init() {
injectCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
injectCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
rootCmd.AddCommand(injectCmd)
}
func injectAction(cmd *cobra.Command, args []string) {
b := build.NewInject(
build.WithHost(gochost),
build.WithMode(gocmode),
build.WithArgs(args),
build.WithDebug(globalDebug),
)
b.OnlyInject()
}

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/build"
"github.com/ar0c/goc/v2/pkg/build"
"github.com/spf13/cobra"
)
@ -28,6 +28,7 @@ var installCmd = &cobra.Command{
func init() {
installCmd.Flags().StringVarP(&gocmode, "gocmode", "", "count", "coverage mode: set, count, atomic, watch")
installCmd.Flags().StringVarP(&gochost, "gochost", "", "127.0.0.1:7777", "specify the host of the goc sever")
installCmd.Flags().StringVarP(&gocextra, "gocextra", "", "", "specify the extra information injected into the build")
rootCmd.AddCommand(installCmd)
}
@ -42,6 +43,7 @@ func installAction(cmd *cobra.Command, args []string) {
build.WithArgs(args),
build.WithInstall(),
build.WithDebug(globalDebug),
build.WithExtra(gocextra),
)
b.Install()

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/spf13/cobra"
"golang.org/x/tools/cover"
"k8s.io/test-infra/gopherage/pkg/cov"

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/client"
"github.com/ar0c/goc/v2/pkg/client"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/spf13/cobra"
)

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/build"
"github.com/ar0c/goc/v2/pkg/build"
"github.com/spf13/cobra"
)

View File

@ -14,9 +14,9 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/RickLeee/goc/v2/pkg/server"
"github.com/RickLeee/goc/v2/pkg/server/store"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/server"
"github.com/ar0c/goc/v2/pkg/server/store"
"github.com/spf13/cobra"
)

30
cmd/server_test.go Normal file
View File

@ -0,0 +1,30 @@
package cmd
import (
"github.com/ar0c/goc/v2/pkg/log"
"github.com/spf13/cobra"
"testing"
)
func Test_serve(t *testing.T) {
type args struct {
cmd *cobra.Command
args []string
}
tests := []struct {
name string
args args
}{
{
name: "",
args: args{},
},
// TODO: Add test cases.
}
for _, tt := range tests {
log.NewLogger(true)
t.Run(tt.name, func(t *testing.T) {
serve(tt.args.cmd, tt.args.args)
})
}
}

View File

@ -14,7 +14,7 @@
package cmd
import (
"github.com/RickLeee/goc/v2/pkg/client"
"github.com/ar0c/goc/v2/pkg/client"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

View File

@ -14,7 +14,7 @@
package cmd
import (
cli "github.com/RickLeee/goc/v2/pkg/watch"
cli "github.com/ar0c/goc/v2/pkg/watch"
"github.com/spf13/cobra"
)

21
go.mod
View File

@ -1,6 +1,8 @@
module github.com/RickLeee/goc/v2
module github.com/ar0c/goc/v2
go 1.20
go 1.22.0
toolchain go1.22.5
require (
github.com/gin-gonic/gin v1.7.2
@ -17,9 +19,9 @@ require (
github.com/stretchr/testify v1.7.0
github.com/tongjingran/copy v1.4.2
go.uber.org/zap v1.17.0
golang.org/x/mod v0.4.2
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
golang.org/x/tools v0.1.3
golang.org/x/mod v0.21.0
golang.org/x/term v0.12.0
golang.org/x/tools v0.13.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
k8s.io/kubectl v0.21.2
k8s.io/test-infra v0.0.0-20210618100605-34aa2f2aa75b
@ -54,13 +56,12 @@ require (
github.com/ugorji/go/codec v1.1.7 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect

24
go.sum
View File

@ -1320,8 +1320,9 @@ golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -1360,8 +1361,8 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -1417,8 +1418,9 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
@ -1524,12 +1526,13 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -1538,8 +1541,9 @@ golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5f
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -1648,8 +1652,8 @@ golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4X
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.3 h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@ -10,7 +10,7 @@ RELEASE_VERSION=$(echo $EVENT_DATA | jq -r .release.tag_name)
PROJECT_NAME=$(basename $GITHUB_REPOSITORY)
NAME="${NAME:-${PROJECT_NAME}-${RELEASE_VERSION}}-${GOOS}-${GOARCH}"
CGO_ENABLED=0 go build -o goc -ldflags "-X 'github.com/RickLeee/goc/v2/cmd.Version=${RELEASE_VERSION}'" .
CGO_ENABLED=0 go build -o goc -ldflags "-X 'github.com/ar0c/goc/v2/cmd.Version=${RELEASE_VERSION}'" .
ARCHIVE=tmp.tar.gz
FILE_LIST=goc

View File

@ -14,7 +14,7 @@
package main
import (
"github.com/RickLeee/goc/v2/cmd"
"github.com/ar0c/goc/v2/cmd"
)
func main() {

View File

@ -45,9 +45,9 @@ var (
token string
id string
cond = sync.NewCond(&sync.Mutex{})
register_extra = ""
commitID string = "{{.CommitID}}"
branch string = "{{.Branch}}"
register_extra = "{{.Extra}}"
)
func init() {
@ -57,6 +57,11 @@ func init() {
host = host_env
}
// init extra information
if os.Getenv("GOC_REGISTER_EXTRA") != "" {
register_extra = os.Getenv("GOC_REGISTER_EXTRA")
}
var dialer = websocket.DefaultDialer
go func() {

View File

@ -18,7 +18,7 @@ import (
"os/exec"
"strings"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/spf13/pflag"
)
@ -31,6 +31,7 @@ type Build struct {
Debug bool
Host string
Mode string // cover mode
Extra string
GOPATH string
GOBIN string
@ -72,6 +73,30 @@ func NewBuild(opts ...gocOption) *Build {
return b
}
func NewInject(opts ...gocOption) *Build {
b := &Build{}
for _, opt := range opts {
opt(b)
}
curWd, err := os.Getwd()
if err != nil {
log.Fatalf("fail to get current working directory: %v", err)
}
b.CurWd = curWd
//// 1. 解析 goc 命令行和 go 命令行
//b.buildCmdArgsParse()
// 2. 解析 go 包位置
b.getPackagesDir()
// 3. 读取工程元信息go.mod, pkgs list ...
b.readProjectMetaInfo(true)
// 4. 展示元信息
b.displayProjectMetaInfo()
return b
}
// Build starts go build
//
// 1. copy project to temp,
@ -97,6 +122,18 @@ func (b *Build) Build() {
b.doBuildInTemp()
}
func (b *Build) OnlyInject() {
// 2. update go.mod file if needed
b.updateGoModFile()
// 3. inject cover vars
b.Inject()
if b.IsVendorMod && b.IsModEdit {
b.reVendor()
}
}
func (b *Build) doBuildInTemp() {
log.StartWait("building the injected project")

View File

@ -20,7 +20,7 @@ import (
"path/filepath"
"strings"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

View File

@ -14,6 +14,8 @@
package build
import (
"strings"
"github.com/spf13/pflag"
)
@ -60,3 +62,9 @@ func WithDebug(enable bool) gocOption {
b.Debug = enable
}
}
func WithExtra(extra string) gocOption {
return func(b *Build) {
b.Extra = strings.TrimSpace(extra)
}
}

View File

@ -23,11 +23,11 @@ import (
"path/filepath"
"strings"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
)
// readProjectMetaInfo reads all meta informations of the corresponding project
func (b *Build) readProjectMetaInfo() {
func (b *Build) readProjectMetaInfo(noTemp ...bool) {
// get gopath & gobin
b.GOPATH = b.readGOPATH()
b.GOBIN = b.readGOBIN()
@ -59,6 +59,9 @@ func (b *Build) readProjectMetaInfo() {
// get tmp folder name
b.TmpModProjectDir = filepath.Join(os.TempDir(), TmpFolderName(b.CurModProjectDir))
if len(noTemp) != 0 && noTemp[0] {
b.TmpModProjectDir = b.CurModProjectDir
}
// get working dir in the corresponding tmp dir
b.TmpWd = filepath.Join(b.TmpModProjectDir, b.CurWd[len(b.CurModProjectDir):])
// get GlobalCoverVarImportPath
@ -71,7 +74,6 @@ func (b *Build) displayProjectMetaInfo() {
log.Infof("GOPATH: %v", b.GOPATH)
log.Infof("GOBIN: %v", b.GOBIN)
log.Infof("Project Directory: %v", b.CurModProjectDir)
log.Infof("GOC_REGISTER_EXTRA from env: %v", os.Getenv("GOC_REGISTER_EXTRA"))
log.Infof("Temporary Project Directory: %v", b.TmpModProjectDir)
if b.IsVendorMod {
log.Infof("Project in vendor mod")

View File

@ -21,9 +21,9 @@ import (
"path/filepath"
"strings"
"github.com/RickLeee/goc/v2/pkg/build/internal/tool"
"github.com/RickLeee/goc/v2/pkg/build/internal/websocket"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/build/internal/tool"
"github.com/ar0c/goc/v2/pkg/build/internal/websocket"
"github.com/ar0c/goc/v2/pkg/log"
)
// Inject injects cover variables for all the .go files in the target directory
@ -195,7 +195,7 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
cmd := exec.Command("git", "rev-parse", "--short=8", "HEAD")
output, err := cmd.Output()
if err != nil {
log.Errorf("git describe Error: %v", err)
log.Errorf("git rev-parse Error: %v", err)
} else {
commitID = strings.TrimRight(string(output), "\n")
}
@ -205,12 +205,7 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
if err != nil {
log.Errorf("get git branch Error: %v", err)
} else {
log.Infof("[goc][info] raw branch: %v ", br)
branch = strings.Replace(string(br), "\n", "", -1)
branch = strings.TrimLeft(branch, "heads/")
branch = strings.Trim(branch, " ")
branch = strings.Replace(branch, "/", "-", -1)
branch = strings.Replace(branch, "_", "-", -1)
branch = fmtBranch(br)
}
log.Infof("[goc][info] branch: %v --- commitID: %v", branch, commitID)
tmplData := struct {
@ -221,6 +216,7 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
Mode string
CommitID string
Branch string
Extra string
}{
Covers: covers,
GlobalCoverVarImportPath: b.GlobalCoverVarImportPath,
@ -229,6 +225,7 @@ func (b *Build) injectGocAgent(where string, covers []*PackageCover) {
Mode: _coverMode,
Branch: branch,
CommitID: commitID,
Extra: b.Extra,
}
if err := coverMainTmpl.Execute(f2, tmplData); err != nil {
@ -317,3 +314,11 @@ func UploadCoverChangeEvent_%v(name string, pos []uint32, i int, stmts uint16) {
log.Fatalf("fail to write to global cover definition file: %v", err)
}
}
func fmtBranch(br []byte) (branch string) {
branch = strings.Replace(string(br), "\n", "", -1)
branch = strings.TrimLeft(branch, "heads/")
branch = strings.Trim(branch, " ")
branch = strings.Replace(branch, "/", "-", -1)
return
}

View File

@ -17,7 +17,7 @@ import (
"os"
"os/exec"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
)
func NewInstall(opts ...gocOption) *Build {

View File

@ -18,7 +18,7 @@ import (
"os"
"sort"
"github.com/RickLeee/goc/v2/pkg/log" // QINIU
"github.com/ar0c/goc/v2/pkg/log" // QINIU
// "cmd/internal/edit"
// "cmd/internal/objabi"
)

View File

@ -21,7 +21,7 @@ import (
"os"
"path/filepath"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
)
//go:embed websocket.tar

View File

@ -18,9 +18,9 @@ import (
"os/exec"
"os/signal"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/RickLeee/goc/v2/pkg/server"
"github.com/RickLeee/goc/v2/pkg/server/store"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/server"
"github.com/ar0c/goc/v2/pkg/server/store"
"github.com/gin-gonic/gin"
)

View File

@ -21,7 +21,7 @@ import (
"path/filepath"
"strings"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/tongjingran/copy"
"golang.org/x/mod/modfile"
)

View File

@ -18,8 +18,8 @@ import (
"fmt"
"os"
"github.com/RickLeee/goc/v2/pkg/client/rest"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/client/rest"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/olekukonko/tablewriter"
)

View File

@ -27,7 +27,7 @@ import (
"golang.org/x/term"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/olekukonko/tablewriter"
)

View File

@ -20,9 +20,9 @@ import (
"os"
"path/filepath"
"github.com/RickLeee/goc/v2/pkg/client/rest"
"github.com/RickLeee/goc/v2/pkg/client/rest/profile"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/client/rest"
"github.com/ar0c/goc/v2/pkg/client/rest/profile"
"github.com/ar0c/goc/v2/pkg/log"
)
func GetProfile(host string, ids []string, skips []string, extra string, output string, need []string) {

View File

@ -14,8 +14,8 @@
package rest
import (
"github.com/RickLeee/goc/v2/pkg/client/rest/agent"
"github.com/RickLeee/goc/v2/pkg/client/rest/profile"
"github.com/ar0c/goc/v2/pkg/client/rest/agent"
"github.com/ar0c/goc/v2/pkg/client/rest/profile"
"github.com/go-resty/resty/v2"
)

View File

@ -22,7 +22,7 @@ import (
"sync"
"time"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/gin-gonic/gin"
"golang.org/x/tools/cover"
"k8s.io/test-infra/gopherage/pkg/cov"

View File

@ -22,7 +22,7 @@ import (
"sync"
"time"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/gin-gonic/gin"
)

View File

@ -25,8 +25,8 @@ import (
"sync/atomic"
"time"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/RickLeee/goc/v2/pkg/server/store"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/server/store"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
)

View File

@ -18,7 +18,7 @@ import (
"sync"
"time"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
)

View File

@ -16,7 +16,7 @@ package watch
import (
"fmt"
"github.com/RickLeee/goc/v2/pkg/log"
"github.com/ar0c/goc/v2/pkg/log"
"github.com/gorilla/websocket"
)