From a4b38e98cce054f59ae9567f2ed519dcb7c5693b Mon Sep 17 00:00:00 2001 From: vmsharoshkin Date: Tue, 22 Sep 2026 13:12:07 +0300 Subject: [PATCH] refactor: move main.go to cmd/eds/main.go Move the entry point to cmd/eds/main.go following the standard Go project layout (cmd//main.go). Update Makefile targets (build, build-one, install) and all documentation references. Fix Go version in release.yml to match go.mod (1.26.6). --- .github/workflows/release.yml | 2 +- CLAUDE.md | 8 ++++---- Makefile | 6 +++--- README.md | 6 +++--- main.go => cmd/eds/main.go | 0 5 files changed, 11 insertions(+), 11 deletions(-) rename main.go => cmd/eds/main.go (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 778eb33..4785575 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.26.6" cache: true - name: build release artifacts diff --git a/CLAUDE.md b/CLAUDE.md index fccd894..5ffdc83 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,8 +41,8 @@ until tests are added. `make all` runs `lint test build` in sequence. Building directly without make: ```bash -go build -o bin/eds . -go run . +go build -o bin/eds ./cmd/eds +go run ./cmd/eds ``` Version is injected at build time via `-ldflags "-X main.version=..."` (see @@ -51,7 +51,7 @@ module path is `github.com/cloud-ru/evolution-devservices-cli`, matching the repo's actual GitHub location — unlike the earlier `evo` rebrand (which kept the pre-rename module path as a cosmetic-only, minimal-diff change), this rename moved the repo itself to a new GitHub org/name, so `go install -github.com/cloud-ru/evolution-devservices-cli@latest` needs the module path +github.com/cloud-ru/evolution-devservices-cli/cmd/eds@latest` needs the module path to match. The internal `Config` struct field names and JSON keys still keep their older spelling (see the `internal/config/config.go` entry below) — that part of the prior minimal-diff choice still applies, since those are @@ -63,7 +63,7 @@ Cobra-based CLI, one command per file under `cmd/`, thin API client under `internal/repoapi/` (Repo product) and generated OpenAPI client under `internal/workflow_client/` (Workflow Studio). -- `main.go` — entry point, wires `main.version` (ldflags) into `cmd.SetVersion`. +- `cmd/eds/main.go` — entry point, wires `main.version` (ldflags) into `cmd.SetVersion`. - `cmd/root.go` — builds the root `eds` command, registers global persistent flags. Product-scoped: `--repo-api-url`, `--repo-git-host` (Repo product); `--wf-api-url` (Workflow Studio). Platform-level (shared, diff --git a/Makefile b/Makefile index be62829..a0081e8 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ build: @mkdir -p $(BUILD_DIR) CGO_ENABLED=$(CGO_ENABLED) go build $(GOFLAGS) \ -trimpath -ldflags '$(LDFLAGS)' \ - -o $(BUILD_DIR)/$(BINARY) . + -o $(BUILD_DIR)/$(BINARY) ./cmd/eds @echo "Built $(BUILD_DIR)/$(BINARY) (version=$(VERSION))" # Helper target - invoke recursively for each os/arch combination. @@ -64,7 +64,7 @@ build-one: $(eval EXE := $(if $(filter windows,$(GOOS)),.exe,)) CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) \ go build $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' \ - -o $(DIST_DIR)/$(BINARY)-$(GOOS)-$(GOARCH)$(EXE) . + -o $(DIST_DIR)/$(BINARY)-$(GOOS)-$(GOARCH)$(EXE) ./cmd/eds @echo " ✔ $(DIST_DIR)/$(BINARY)-$(GOOS)-$(GOARCH)$(EXE)" .PHONY: build-all @@ -148,7 +148,7 @@ upload-latest: .PHONY: install install: CGO_ENABLED=$(CGO_ENABLED) go install $(GOFLAGS) \ - -trimpath -ldflags '$(LDFLAGS)' $(PKG) + -trimpath -ldflags '$(LDFLAGS)' $(PKG)/cmd/eds .PHONY: test test: diff --git a/README.md b/README.md index d1e3478..dd34fa5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ chmod +x eds && sudo mv eds /usr/local/bin/eds ```bash git clone git@github.com:cloud-ru/evolution-devservices-cli.git cd evolution-devservices-cli -go install github.com/cloud-ru/evolution-devservices-cli@latest +go install github.com/cloud-ru/evolution-devservices-cli/cmd/eds@latest # or make build # ./bin/eds make build-all # cross-compile darwin/linux × amd64/arm64 into ./dist/ @@ -293,9 +293,9 @@ make help # list targets Project layout: ``` -main.go # entry point + ldflags-driven version cmd/ - root.go # cobra root command (`eds`) + global flags + eds/main.go # entry point + ldflags-driven version + root.go # cobra root command (`eds`) + global flags helpers.go # config resolution, runtime context login.go # `eds login` config.go # `eds config` diff --git a/main.go b/cmd/eds/main.go similarity index 100% rename from main.go rename to cmd/eds/main.go