embedfs-web-go

command module
v0.0.0-...-f176f54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2024 License: MIT Imports: 10 Imported by: 0

README

embedfs-web-go

Example of running a file server using //go:embed.

Run locally

go run main.go --addr "localhost:8080"

Run as a static binary

go build -o fileserver .
./fileserver --addr "localhost:8080"

Run as a Docker image

Please note socket bind to the virtual ethernet device (0.0.0.0) rather than loopback (localhost):

docker build . -t fileserver
docker run -it --rm -p 8080:8080 --user 65534:65534 \
  fileserver --addr 0.0.0.0:8080

Change the path

To change the path from static, update the path in both the constant variable, and the //go:embed directive:

--- main.go     2024-05-29 19:06:09
+++ main2.go    2024-05-29 19:25:09
@@ -15,9 +15,9 @@
-const path = "static"
+const path = "path/to/dir"

-//go:embed static
+//go:embed path/to/dir

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL