[GH-ISSUE #1987] Go Example code doesn't work #241

Open
opened 2026-03-03 12:09:22 +03:00 by kerem · 2 comments
Owner

Originally created by @djnym on GitHub (Jul 15, 2025).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1987

Ran into a problem and can reproduce it with main branch and example code as below.

Checkout and build docker image

$ git clone https://github.com/fsouza/fake-gcs-server.git
Cloning into 'fake-gcs-server'...
remote: Enumerating objects: 10898, done.
remote: Counting objects: 100% (1510/1510), done.
remote: Compressing objects: 100% (253/253), done.
remote: Total 10898 (delta 1440), reused 1257 (delta 1257), pack-reused 9388 (from 4)
Receiving objects: 100% (10898/10898), 3.81 MiB | 8.42 MiB/s, done.
Resolving deltas: 100% (7670/7670), done.
$ cd fake-gcs-server
$ docker build -t fsouza/fake-gcs-server .
[+] Building 19.8s (18/18) FINISHED                                                                                      docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                     0.0s
 => => transferring dockerfile: 547B                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/alpine:3.22.0                                                                         0.9s
 => [internal] load metadata for docker.io/library/golang:1.24                                                                           0.9s
 => [auth] library/golang:pull token for registry-1.docker.io                                                                            0.0s
 => [auth] library/alpine:pull token for registry-1.docker.io                                                                            0.0s
 => [internal] load .dockerignore                                                                                                        0.0s
 => => transferring context: 87B                                                                                                         0.0s
 => [builder 1/6] FROM docker.io/library/golang:1.24@sha256:14fd8a55e59a560704e5fc44970b301d00d344e45d6b914dda228e09f359a088             0.0s
 => => resolve docker.io/library/golang:1.24@sha256:14fd8a55e59a560704e5fc44970b301d00d344e45d6b914dda228e09f359a088                     0.0s
 => [stage-1 1/4] FROM docker.io/library/alpine:3.22.0@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715           0.0s
 => => resolve docker.io/library/alpine:3.22.0@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715                   0.0s
 => [internal] load build context                                                                                                        0.0s
 => => transferring context: 406.76kB                                                                                                    0.0s
 => CACHED [stage-1 2/4] RUN apk add --no-cache mailcap                                                                                  0.0s
 => CACHED [builder 2/6] WORKDIR /code                                                                                                   0.0s
 => CACHED [builder 3/6] ADD go.mod go.sum ./                                                                                            0.0s
 => CACHED [builder 4/6] RUN go mod download                                                                                             0.0s
 => [builder 5/6] ADD . ./                                                                                                               0.0s
 => [builder 6/6] RUN go build -o fake-gcs-server                                                                                       17.4s
 => [stage-1 3/4] COPY --from=builder /code/fake-gcs-server /bin/fake-gcs-server                                                         0.1s
 => [stage-1 4/4] RUN /bin/fake-gcs-server -h                                                                                            0.1s
 => exporting to image                                                                                                                   1.2s
 => => exporting layers                                                                                                                  1.0s
 => => exporting manifest sha256:baa48d81cd365a715dbb1cfd2ea0129da22ab7828e13f08816a7f8a9e59355ca                                        0.0s
 => => exporting config sha256:d6579af17a94ac0894ebf5f112a3d2b358388ca3632d8684d40c1955f225dcf5                                          0.0s
 => => exporting attestation manifest sha256:863e09458c1eb138bc92eecdd47db911d85076ac0a1dee60a79e68e000f9b526                            0.0s
 => => exporting manifest list sha256:328dbaa85318d4d93a94ae5237e9e78cfcaabccf86f364129911c1c2d1f1e412                                   0.0s
 => => naming to docker.io/fsouza/fake-gcs-server:latest                                                                                 0.0s
 => => unpacking to docker.io/fsouza/fake-gcs-server:latest                                                                              0.1s

Run docker image

$ docker run --rm -d --name fake-gcs-server -p 8080:8080 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server:latest -scheme http -port 8080
db07f6ed759a50d9469ac21f01aee49c86788f23068a22d71a3e6928fd5d8ace

Run example code

$ cd examples/go
$ go run main.go
buckets: [some_file.txt]
2025/07/15 14:47:36 storage: object doesn't exist
exit status 1
Originally created by @djnym on GitHub (Jul 15, 2025). Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/1987 Ran into a problem and can reproduce it with main branch and example code as below. ### Checkout and build docker image ``` $ git clone https://github.com/fsouza/fake-gcs-server.git Cloning into 'fake-gcs-server'... remote: Enumerating objects: 10898, done. remote: Counting objects: 100% (1510/1510), done. remote: Compressing objects: 100% (253/253), done. remote: Total 10898 (delta 1440), reused 1257 (delta 1257), pack-reused 9388 (from 4) Receiving objects: 100% (10898/10898), 3.81 MiB | 8.42 MiB/s, done. Resolving deltas: 100% (7670/7670), done. $ cd fake-gcs-server $ docker build -t fsouza/fake-gcs-server . [+] Building 19.8s (18/18) FINISHED docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 547B 0.0s => [internal] load metadata for docker.io/library/alpine:3.22.0 0.9s => [internal] load metadata for docker.io/library/golang:1.24 0.9s => [auth] library/golang:pull token for registry-1.docker.io 0.0s => [auth] library/alpine:pull token for registry-1.docker.io 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 87B 0.0s => [builder 1/6] FROM docker.io/library/golang:1.24@sha256:14fd8a55e59a560704e5fc44970b301d00d344e45d6b914dda228e09f359a088 0.0s => => resolve docker.io/library/golang:1.24@sha256:14fd8a55e59a560704e5fc44970b301d00d344e45d6b914dda228e09f359a088 0.0s => [stage-1 1/4] FROM docker.io/library/alpine:3.22.0@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715 0.0s => => resolve docker.io/library/alpine:3.22.0@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715 0.0s => [internal] load build context 0.0s => => transferring context: 406.76kB 0.0s => CACHED [stage-1 2/4] RUN apk add --no-cache mailcap 0.0s => CACHED [builder 2/6] WORKDIR /code 0.0s => CACHED [builder 3/6] ADD go.mod go.sum ./ 0.0s => CACHED [builder 4/6] RUN go mod download 0.0s => [builder 5/6] ADD . ./ 0.0s => [builder 6/6] RUN go build -o fake-gcs-server 17.4s => [stage-1 3/4] COPY --from=builder /code/fake-gcs-server /bin/fake-gcs-server 0.1s => [stage-1 4/4] RUN /bin/fake-gcs-server -h 0.1s => exporting to image 1.2s => => exporting layers 1.0s => => exporting manifest sha256:baa48d81cd365a715dbb1cfd2ea0129da22ab7828e13f08816a7f8a9e59355ca 0.0s => => exporting config sha256:d6579af17a94ac0894ebf5f112a3d2b358388ca3632d8684d40c1955f225dcf5 0.0s => => exporting attestation manifest sha256:863e09458c1eb138bc92eecdd47db911d85076ac0a1dee60a79e68e000f9b526 0.0s => => exporting manifest list sha256:328dbaa85318d4d93a94ae5237e9e78cfcaabccf86f364129911c1c2d1f1e412 0.0s => => naming to docker.io/fsouza/fake-gcs-server:latest 0.0s => => unpacking to docker.io/fsouza/fake-gcs-server:latest 0.1s ``` ### Run docker image ``` $ docker run --rm -d --name fake-gcs-server -p 8080:8080 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server:latest -scheme http -port 8080 db07f6ed759a50d9469ac21f01aee49c86788f23068a22d71a3e6928fd5d8ace ``` ### Run example code ``` $ cd examples/go $ go run main.go buckets: [some_file.txt] 2025/07/15 14:47:36 storage: object doesn't exist exit status 1 ```
Author
Owner

@timtatt commented on GitHub (Jul 17, 2025):

Ran into this same problem, found that if the ports are mapped to a different external port i.e 1234:4443, you need to provide -public-url localhost:1234 as a command to the docker image

In your case may be as simple as -public-url localhost:8080

<!-- gh-comment-id:3083506380 --> @timtatt commented on GitHub (Jul 17, 2025): Ran into this same problem, found that if the ports are mapped to a different external port i.e 1234:4443, you need to provide `-public-url localhost:1234` as a command to the docker image In your case may be as simple as `-public-url localhost:8080`
Author
Owner

@sooncj commented on GitHub (Feb 4, 2026):

in the latest version it worked for me with -public-host localhost

<!-- gh-comment-id:3848396332 --> @sooncj commented on GitHub (Feb 4, 2026): in the latest version it worked for me with `-public-host localhost`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/fake-gcs-server#241
No description provided.