From 7b65695ba9bfb47a90e4dbc9c4f8aa99e59017b0 Mon Sep 17 00:00:00 2001 From: Michael McQuade Date: Sun, 12 Jul 2026 21:05:03 -0500 Subject: [PATCH] Fix review follow-ups from the embeddable-cli change Stamp VersionNumber from the release tag instead of a hardcoded literal that drifts, inline the pass-through mount wrapper, gofmt the tree, and gate CI on gofmt so it stays clean. Claude-Session: https://claude.ai/code/session_0191kNQ9ZxzwEng9QfcfBKe6 --- .github/workflows/ci.yml | 3 +++ .github/workflows/release.yml | 4 ++-- cli/cli.go | 17 +++++------------ example/test_api.go | 2 +- internal/backend.go | 14 +++++++------- internal/goofys_test.go | 10 +++++----- internal/utils.go | 2 +- 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93d927cb..56aa6436 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,9 @@ jobs: with: go-version: stable + - name: gofmt + run: test -z "$(gofmt -l .)" || { gofmt -l .; exit 1; } + - name: Build env: CGO_ENABLED: '0' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 001a58f6..e62714a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,8 +22,8 @@ jobs: env: CGO_ENABLED: '0' run: | - GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$GITHUB_REF_NAME" -o goofys-amd64 . - GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X main.Version=$GITHUB_REF_NAME" -o goofys-arm64 . + GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$GITHUB_REF_NAME -X github.com/kahing/goofys/internal.VersionNumber=${GITHUB_REF_NAME#v}" -o goofys-amd64 . + GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X main.Version=$GITHUB_REF_NAME -X github.com/kahing/goofys/internal.VersionNumber=${GITHUB_REF_NAME#v}" -o goofys-arm64 . cp goofys-amd64 goofys - name: Create release and upload assets diff --git a/cli/cli.go b/cli/cli.go index 052a400e..22ec3c9f 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -102,16 +102,6 @@ func kill(pid int, s os.Signal) (err error) { return } -// Mount the file system based on the supplied arguments, returning a -// fuse.MountedFileSystem that can be joined to wait for unmounting. -func mount( - ctx context.Context, - bucketName string, - flags *FlagStorage) (fs *Goofys, mfs *fuse.MountedFileSystem, err error) { - - return goofys.Mount(ctx, bucketName, flags) -} - func massagePath() { for _, e := range os.Environ() { if strings.HasPrefix(e, "PATH=") { @@ -142,7 +132,10 @@ func massageArg0() { // binaries can embed goofys and dispatch to it; note it may daemonize by // re-executing os.Args[0] and can terminate the process on fatal errors. func Run(args []string, versionHash string) int { - VersionNumber = "0.25.0" + // release builds stamp internal.VersionNumber from the tag via ldflags + if VersionNumber == "" { + VersionNumber = "0.0.0-dev" + } VersionHash = versionHash massagePath() @@ -213,7 +206,7 @@ func Run(args []string, versionHash string) int { // Mount the file system. var mfs *fuse.MountedFileSystem var fs *Goofys - fs, mfs, err = mount( + fs, mfs, err = goofys.Mount( context.Background(), bucketName, flags) diff --git a/example/test_api.go b/example/test_api.go index 2bb126dc..1b5f3837 100644 --- a/example/test_api.go +++ b/example/test_api.go @@ -4,8 +4,8 @@ import ( goofys "github.com/kahing/goofys/api" common "github.com/kahing/goofys/api/common" - "fmt" "context" + "fmt" ) func main() { diff --git a/internal/backend.go b/internal/backend.go index 414e291d..71537985 100644 --- a/internal/backend.go +++ b/internal/backend.go @@ -215,13 +215,13 @@ type MakeBucketOutput struct { RequestId string } -/// Implementations of all the functions here are expected to be -/// concurrency-safe, except for -/// -/// Init() is called exactly once before any other functions are -/// called. -/// -/// Capabilities()/Bucket() are expected to be const +// / Implementations of all the functions here are expected to be +// / concurrency-safe, except for +// / +// / Init() is called exactly once before any other functions are +// / called. +// / +// / Capabilities()/Bucket() are expected to be const type StorageBackend interface { Init(key string) error Capabilities() *Capabilities diff --git a/internal/goofys_test.go b/internal/goofys_test.go index 16b86773..2b6196d1 100644 --- a/internal/goofys_test.go +++ b/internal/goofys_test.go @@ -166,11 +166,11 @@ func (t *GoofysTest) deleteBlobsParallelly(cloud StorageBackend, blobs []string) // groupByDecresingDepths takes a slice of path strings and returns the paths as // groups where each group has the same `depth` - depth(a/b/c)=2, depth(a/b/)=1 // The groups are returned in decreasing order of depths. -// - Inp: [] Out: [] -// - Inp: ["a/b1/", "a/b/c1", "a/b2", "a/b/c2"] -// Out: [["a/b/c1", "a/b/c2"], ["a/b1/", "a/b2"]] -// - Inp: ["a/b1/", "z/a/b/c1", "a/b2", "z/a/b/c2"] -// Out: [["z/a/b/c1", "z/a/b/c2"], ["a/b1/", "a/b2"] +// - Inp: [] Out: [] +// - Inp: ["a/b1/", "a/b/c1", "a/b2", "a/b/c2"] +// Out: [["a/b/c1", "a/b/c2"], ["a/b1/", "a/b2"]] +// - Inp: ["a/b1/", "z/a/b/c1", "a/b2", "z/a/b/c2"] +// Out: [["z/a/b/c1", "z/a/b/c2"], ["a/b1/", "a/b2"] func groupByDecresingDepths(items []string) [][]string { depthToGroup := map[int][]string{} for _, item := range items { diff --git a/internal/utils.go b/internal/utils.go index 97b549aa..f54c690d 100644 --- a/internal/utils.go +++ b/internal/utils.go @@ -245,4 +245,4 @@ func ConvertBytesToIEC(size int64) string { exp += 1 } return fmt.Sprintf("%.1f %ciB", curSize, "KMGTPEZY"[exp-1]) -} \ No newline at end of file +}