minor tweaks

This commit is contained in:
stryan 2023-08-08 18:07:05 -04:00
parent c13f1ecea5
commit 9e83028509
2 changed files with 11 additions and 9 deletions

View File

@ -1,13 +1,14 @@
FROM golang:1.18 as builder
FROM golang:1.20-alpine as builder
WORKDIR /go/src/app
COPY . .
RUN apt update && apt upgrade -y
RUN go build
#RUN apt update && apt upgrade -y
RUN CGO_ENABLED=0 go build
FROM alpine:latest as final
WORKDIR /srv/
RUN mkdir /srv/dota_patch_bot
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN apk add libc6-compat
#RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
COPY --from=builder /go/src/app/dota_patch_bot /srv/dota_patch_bot/
CMD ["/srv/dota_patch_bot/dota_patch_bot"]

11
main.go
View File

@ -5,7 +5,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"os"
@ -37,7 +37,7 @@ func loadPatches(pl *patchList, url string) {
}
defer res.Body.Close()
body, readErr := ioutil.ReadAll(res.Body)
body, readErr := io.ReadAll(res.Body)
if readErr != nil {
log.Fatal(readErr)
}
@ -48,7 +48,6 @@ func loadPatches(pl *patchList, url string) {
}
func notify(ptch patch, url string) {
type Payload struct {
Text string `json:"text"`
Format string `json:"format"`
@ -96,9 +95,12 @@ func notify(ptch patch, url string) {
if err != nil {
log.Println("error posting to webhook")
}
defer resp.Body.Close()
if resp.Body != nil {
resp.Body.Close()
}
}
}
func main() {
hookPtr := flag.String("hook", "", "the webhook to notify")
sourcePtr := flag.String("url", "https://www.dota2.com/datafeed/patchnoteslist", "url to fetch patchnotes from")
@ -147,5 +149,4 @@ func main() {
}
}
}
}