diff --git a/Taskfile.yml b/Taskfile.yml index de548953..d4379901 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -3,20 +3,35 @@ version: '3' vars: VERSION: sh: git describe --tags --exact-match 2>/dev/null || echo "dev" - LDFLAGS: "-X github.com/host-uk/core/pkg/cli.AppVersion={{.VERSION}}" + # Base ldflags for version injection + LDFLAGS_BASE: "-X github.com/host-uk/core/pkg/cli.AppVersion={{.VERSION}}" + # Development build: includes debug info + LDFLAGS: "{{.LDFLAGS_BASE}}" + # Release build: strips debug info and symbol table for smaller binary + LDFLAGS_RELEASE: "-s -w {{.LDFLAGS_BASE}}" tasks: # --- CLI Management --- cli:build: - desc: "Build core CLI to ./bin/core" + desc: "Build core CLI to ./bin/core (dev build with debug info)" cmds: - go build -ldflags '{{.LDFLAGS}}' -o ./bin/core . + cli:build:release: + desc: "Build core CLI for release (smaller binary, no debug info)" + cmds: + - go build -ldflags '{{.LDFLAGS_RELEASE}}' -o ./bin/core . + cli:install: - desc: "Install core CLI to system PATH" + desc: "Install core CLI to system PATH (dev build)" cmds: - go install -ldflags '{{.LDFLAGS}}' . + cli:install:release: + desc: "Install core CLI for release (smaller binary)" + cmds: + - go install -ldflags '{{.LDFLAGS_RELEASE}}' . + # --- Development --- test: desc: "Run all tests" diff --git a/internal/cmd/setup/cmd_registry.go b/internal/cmd/setup/cmd_registry.go index d9714329..a06e10ef 100644 --- a/internal/cmd/setup/cmd_registry.go +++ b/internal/cmd/setup/cmd_registry.go @@ -117,7 +117,7 @@ func runRegistrySetupWithReg(ctx context.Context, reg *repos.Registry, registryP // Check if already exists repoPath := filepath.Join(basePath, repo.Name) - // Check .git dir existence via List + // Check .git dir existence via Exists if coreio.Local.Exists(filepath.Join(repoPath, ".git")) { exists++ continue diff --git a/pkg/container/state.go b/pkg/container/state.go index 53ab1e2a..b8d98b97 100644 --- a/pkg/container/state.go +++ b/pkg/container/state.go @@ -99,13 +99,19 @@ func (s *State) Add(c *Container) error { return s.SaveState() } -// Get retrieves a container by ID. +// Get retrieves a copy of a container by ID. +// Returns a copy to prevent data races when the container is modified. func (s *State) Get(id string) (*Container, bool) { s.mu.RLock() defer s.mu.RUnlock() c, ok := s.Containers[id] - return c, ok + if !ok { + return nil, false + } + // Return a copy to prevent data races + copy := *c + return ©, true } // Update updates a container in the state and persists it. @@ -126,14 +132,16 @@ func (s *State) Remove(id string) error { return s.SaveState() } -// All returns all containers in the state. +// All returns copies of all containers in the state. +// Returns copies to prevent data races when containers are modified. func (s *State) All() []*Container { s.mu.RLock() defer s.mu.RUnlock() containers := make([]*Container, 0, len(s.Containers)) for _, c := range s.Containers { - containers = append(containers, c) + copy := *c + containers = append(containers, ©) } return containers }