From 8ed76297c95aa2972b5baa2d199ec11e045206c7 Mon Sep 17 00:00:00 2001 From: Qi Xiao Date: Thu, 22 Feb 2024 13:00:04 +0000 Subject: [PATCH] Make app/ a Go module. --- Dockerfile | 2 +- app/go.mod | 3 +++ app/up.go | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 app/go.mod diff --git a/Dockerfile b/Dockerfile index 1a22c5b..1dc13a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apk --no-cache add git make rsync zip python3 py3-beautifulsoup4 coreutils # Build app COPY app /app -RUN go build -o /app/up /app/up.go +RUN cd /app && go build -o up . # Set up user and directories. RUN adduser -D -g '' builder diff --git a/app/go.mod b/app/go.mod new file mode 100644 index 0000000..a091a3c --- /dev/null +++ b/app/go.mod @@ -0,0 +1,3 @@ +module github.com/elves/up/app + +go 1.22.0 diff --git a/app/up.go b/app/up.go index bea9ef5..f4c881e 100644 --- a/app/up.go +++ b/app/up.go @@ -8,7 +8,7 @@ import ( "encoding/hex" "encoding/json" "flag" - "io/ioutil" + "io" "log" "net/http" "os" @@ -29,7 +29,7 @@ type Payload struct { func main() { flag.Parse() - secretBytes, err := ioutil.ReadFile(*secretFlag) + secretBytes, err := os.ReadFile(*secretFlag) if err != nil { log.Fatalln("failed to read secret file:", err) } @@ -40,7 +40,7 @@ func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { log.Println("handling request") - payload, err := ioutil.ReadAll(r.Body) + payload, err := io.ReadAll(r.Body) if err != nil { log.Println("failed to read HTTP request:", err) return