Skip to content

Commit

Permalink
restructure cmd folder
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Mar 24, 2024
1 parent 57c6ee4 commit 4813381
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 39 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ updatedeps: versioncheck
$(MAKE) cleandeps

cleandeps:
set -e; for dir in $(shell ls -d1 pkg/* cmd/*); do \
set -e; for dir in $(shell ls -d1 pkg/* pkg/snclient/commands cmd/*); do \
( cd ./$$dir && $(GO) mod tidy ); \
done
$(GO) mod tidy
Expand All @@ -130,7 +130,7 @@ go.work: pkg/*
$(GO) work use \
. \
pkg/* \
pkg/snclient/cmd \
pkg/snclient/commands \
cmd/* \
buildtools/. \
t/. \
Expand Down Expand Up @@ -204,16 +204,16 @@ rsrc_windows_arm64.syso: winres | tools
${TOOLSFOLDER}/go-winres make --arch arm64

test: vendor
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -short -v $(TEST_FLAGS) pkg/* pkg/*/cmd
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -short -v $(TEST_FLAGS) pkg/* pkg/*/commands
if grep -Irn TODO: ./cmd/ ./pkg/ ./packaging/ ; then exit 1; fi
if grep -Irn Dump ./cmd/ ./pkg/ | grep -v dump.go | grep -v DumpRe | grep -v ThreadDump; then exit 1; fi

# test with filter
testf: vendor
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -short -v $(TEST_FLAGS) pkg/* pkg/*/cmd -run "$(filter-out $@,$(MAKECMDGOALS))" 2>&1 | grep -v "no test files" | grep -v "no tests to run" | grep -v "^PASS"
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -short -v $(TEST_FLAGS) pkg/* pkg/*/commands -run "$(filter-out $@,$(MAKECMDGOALS))" 2>&1 | grep -v "no test files" | grep -v "no tests to run" | grep -v "^PASS"

longtest: vendor
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -v $(TEST_FLAGS) pkg/* pkg/*/cmd
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -v $(TEST_FLAGS) pkg/* pkg/*/commands

citest: tools vendor
#
Expand Down Expand Up @@ -269,19 +269,19 @@ citest: tools vendor
#

benchmark:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(TEST_FLAGS) -v -bench=B\* -run=^$$ -benchmem ./pkg/* pkg/*/cmd
CGO_ENABLED=$(CGO_ENABLED) $(GO) test $(TEST_FLAGS) -v -bench=B\* -run=^$$ -benchmem ./pkg/* pkg/*/commands

racetest:
# go: -race requires cgo, so do not use the macro here
$(GO) test -race $(TEST_FLAGS) -coverprofile=coverage.txt -covermode=atomic ./pkg/* pkg/*/cmd
$(GO) test -race $(TEST_FLAGS) -coverprofile=coverage.txt -covermode=atomic ./pkg/* pkg/*/commands

covertest:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/* pkg/*/cmd
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/* pkg/*/commands
$(GO) tool cover -func=cover.out
$(GO) tool cover -html=cover.out -o coverage.html

coverweb:
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/* pkg/*/cmd
CGO_ENABLED=$(CGO_ENABLED) $(GO) test -v $(TEST_FLAGS) -coverprofile=cover.out ./pkg/* pkg/*/commands
$(GO) tool cover -html=cover.out

clean:
Expand Down Expand Up @@ -337,7 +337,7 @@ golangci: tools
# golangci combines a few static code analyzer
# See https://github.com/golangci/golangci-lint
#
@set -e; for dir in $$(ls -1d pkg/* pkg/snclient/cmd cmd t); do \
@set -e; for dir in $$(ls -1d pkg/* pkg/snclient/commands cmd t); do \
echo $$dir; \
if [ $$dir != "pkg/eventlog" ]; then \
echo " - GOOS=linux"; \
Expand Down
4 changes: 2 additions & 2 deletions cmd/snclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"os"

"pkg/snclient/cmd"
"pkg/snclient/commands"
)

func main() {
if err := cmd.Execute(); err != nil {
if err := commands.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ replace pkg/nrpe => ./pkg/nrpe

replace pkg/snclient => ./pkg/snclient

replace pkg/snclient/cmd => ./pkg/snclient/cmd
replace pkg/snclient/commands => ./pkg/snclient/commands

replace pkg/utils => ./pkg/utils

Expand All @@ -29,7 +29,7 @@ replace github.com/shirou/gopsutil/v3 => github.com/sni/gopsutil/v3 v3.0.0-20240

require (
github.com/stretchr/testify v1.9.0
pkg/snclient/cmd v0.0.0-00010101000000-000000000000
pkg/snclient/commands v0.0.0-00010101000000-000000000000
pkg/utils v0.0.0-00010101000000-000000000000
)

Expand All @@ -55,18 +55,17 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/miekg/dns v1.1.58 // indirect
github.com/onsi/gomega v1.31.1 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.51.0 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/reeflective/readline v1.0.13 // indirect
github.com/reeflective/readline v1.0.14 // indirect
github.com/rickb777/date v1.20.6 // indirect
github.com/rickb777/plural v1.4.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/sassoftware/go-rpmutils v0.3.0 // indirect
github.com/sevlyar/go-daemon v0.1.6 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo=
github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0=
github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=
github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M=
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
Expand All @@ -93,16 +93,16 @@ github.com/prometheus/common v0.51.0 h1:vT5R9NAlW4V6k8Wruk7ikrHaHRsrPbduM/cKTOdQ
github.com/prometheus/common v0.51.0/go.mod h1:wHFBCEVWVmHMUpg7pYcOm2QUR/ocQdYSJVQJKnHc3xQ=
github.com/prometheus/procfs v0.13.0 h1:GqzLlQyfsPbaEHaQkO7tbDlriv/4o5Hudv6OXHGKX7o=
github.com/prometheus/procfs v0.13.0/go.mod h1:cd4PFCR54QLnGKPaKGA6l+cfuNXtht43ZKY6tow0Y1g=
github.com/reeflective/readline v1.0.13 h1:TeJmYw9B7VRPZWfNExr9QHxL1m0iSicyqBSQIRn39Ss=
github.com/reeflective/readline v1.0.13/go.mod h1:3iOe/qyb2jEy0KqLrNlb/CojBVqxga9ACqz/VU22H6A=
github.com/reeflective/readline v1.0.14 h1:sgKLpi3figH8IcWx3Hu3rCeGJQ6W+6KtZ3PTdcAD3jA=
github.com/reeflective/readline v1.0.14/go.mod h1:3iOe/qyb2jEy0KqLrNlb/CojBVqxga9ACqz/VU22H6A=
github.com/rickb777/date v1.14.2/go.mod h1:swmf05C+hN+m8/Xh7gEq3uB6QJDNc5pQBWojKdHetOs=
github.com/rickb777/date v1.20.6 h1:DQ4QZDcJt+CytSnkFgL0JtQWO0NXN3SaXcTUovoxXhk=
github.com/rickb777/date v1.20.6/go.mod h1:k/6AwXJ0l62oPgZlZ60/Jnf3m+6aTIJQ5Wp/gMpUhSg=
github.com/rickb777/plural v1.2.2/go.mod h1:xyHbelv4YvJE51gjMnHvk+U2e9zIysg6lTnSQK8XUYA=
github.com/rickb777/plural v1.4.1 h1:5MMLcbIaapLFmvDGRT5iPk8877hpTPt8Y9cdSKRw9sU=
github.com/rickb777/plural v1.4.1/go.mod h1:kdmXUpmKBJTS0FtG/TFumd//VBWsNTD7zOw7x4umxNw=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down
3 changes: 0 additions & 3 deletions pkg/snclient/cmd/go.mod

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"pkg/snclient"
Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/cmd/dev.go → pkg/snclient/commands/dev.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"pkg/snclient"
Expand Down
4 changes: 4 additions & 0 deletions pkg/snclient/commands/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module commands

go 1.22

2 changes: 1 addition & 1 deletion pkg/snclient/cmd/hash.go → pkg/snclient/commands/hash.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package cmd
package commands

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/cmd/root.go → pkg/snclient/commands/root.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"pkg/snclient"
Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/cmd/test.go → pkg/snclient/commands/test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package cmd
package commands

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package commands

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//go:build windows

package cmd
package commands

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ replace pkg/nrpe => ../../pkg/nrpe

replace pkg/snclient => ../../pkg/snclient

replace pkg/snclient/cmd => ../../pkg/snclient/cmd
replace pkg/snclient/commands => ../../pkg/snclient/commands

replace pkg/utils => ../../pkg/utils

Expand Down

0 comments on commit 4813381

Please sign in to comment.