diff --git a/Dockerfile b/Dockerfile index e1a424b..587d956 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.15-alpine3.13 as build +FROM golang:1.16-alpine3.13 as build RUN apk add --no-cache git gcc musl-dev sqlite-dev ADD *.go /app/ ADD go.mod /app/ diff --git a/activityPub.go b/activityPub.go index 4bfe553..c058641 100644 --- a/activityPub.go +++ b/activityPub.go @@ -8,10 +8,10 @@ import ( "encoding/pem" "errors" "fmt" - "io/ioutil" "log" "net/http" "net/url" + "os" "regexp" "strings" "sync" @@ -46,7 +46,7 @@ func initActivityPub() error { p.apDelete() }) // Read key and prepare signing - pkfile, err := ioutil.ReadFile(appConfig.ActivityPub.KeyPath) + pkfile, err := os.ReadFile(appConfig.ActivityPub.KeyPath) if err != nil { return err } diff --git a/activityPubSending.go b/activityPubSending.go index e20a67a..65105ef 100644 --- a/activityPubSending.go +++ b/activityPubSending.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/url" @@ -130,7 +130,7 @@ func apSendSigned(blogIri, to string, activity []byte) error { return err } if !apRequestIsSuccess(resp.StatusCode) { - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) _ = resp.Body.Close() return fmt.Errorf("signed request failed with status %d: %s", resp.StatusCode, string(body)) } diff --git a/authentication.go b/authentication.go index 4d7ffa9..29619b9 100644 --- a/authentication.go +++ b/authentication.go @@ -5,7 +5,6 @@ import ( "encoding/base64" "encoding/json" "io" - "io/ioutil" "net/http" "time" @@ -44,7 +43,7 @@ func authMiddleware(next http.Handler) http.Handler { // 3. Show login form w.WriteHeader(http.StatusUnauthorized) h, _ := json.Marshal(r.Header.Clone()) - b, _ := ioutil.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte + b, _ := io.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte _ = r.Body.Close() if len(b) == 0 { // Maybe it's a form diff --git a/cache.go b/cache.go index ac261d3..9b79f20 100644 --- a/cache.go +++ b/cache.go @@ -5,7 +5,6 @@ import ( "crypto/sha256" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "strconv" @@ -122,7 +121,7 @@ func getCache(key string, next http.Handler, r *http.Request) (item *cacheItem) next.ServeHTTP(recorder, r) // Cache values from recorder result := recorder.Result() - body, _ := ioutil.ReadAll(result.Body) + body, _ := io.ReadAll(result.Body) _ = result.Body.Close() eTag := result.Header.Get("ETag") if eTag == "" { diff --git a/captcha.go b/captcha.go index 5a4961f..9c75a74 100644 --- a/captcha.go +++ b/captcha.go @@ -5,7 +5,6 @@ import ( "encoding/base64" "encoding/json" "io" - "io/ioutil" "net/http" "time" @@ -28,7 +27,7 @@ func captchaMiddleware(next http.Handler) http.Handler { // 2. Show Captcha w.WriteHeader(http.StatusUnauthorized) h, _ := json.Marshal(r.Header.Clone()) - b, _ := ioutil.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte + b, _ := io.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte _ = r.Body.Close() if len(b) == 0 { // Maybe it's a form diff --git a/go.mod b/go.mod index c02ae6b..85b07b7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module git.jlel.se/jlelse/GoBlog -go 1.15 +go 1.16 require ( codeberg.org/jlelse/tinify v0.0.0-20200123222407-7fc9c21822b0 @@ -54,7 +54,7 @@ require ( golang.org/x/mod v0.4.1 // indirect golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect golang.org/x/sync v0.0.0-20201207232520-09787c993a3a - golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect + golang.org/x/sys v0.0.0-20210216224549-f992740a1bac // indirect golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect golang.org/x/text v0.3.5 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum index c5c19e5..299b167 100644 --- a/go.sum +++ b/go.sum @@ -404,8 +404,8 @@ golang.org/x/sys v0.0.0-20200724161237-0e2f3a69832c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210216224549-f992740a1bac h1:9glrpwtNjBYgRpb67AZJKHfzj1stG/8BL5H7In2oTC4= +golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M= diff --git a/micropubMedia.go b/micropubMedia.go index d804eee..1acb921 100644 --- a/micropubMedia.go +++ b/micropubMedia.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime" "mime/multipart" "net/http" @@ -147,7 +146,7 @@ func tinify(url string, config *configMicropubMedia) (location string, err error }); err != nil { return "", err } - tmpFile, err := ioutil.TempFile("", "tiny-*."+fileExtension) + tmpFile, err := os.CreateTemp("", "tiny-*."+fileExtension) if err != nil { return "", err } @@ -200,7 +199,7 @@ func shortPixel(url string, config *configMicropubMedia) (location string, err e } else if resp.StatusCode != http.StatusOK { return "", fmt.Errorf("failed to compress image, status code %d", resp.StatusCode) } - tmpFile, err := ioutil.TempFile("", "tiny-*."+fileExtension) + tmpFile, err := os.CreateTemp("", "tiny-*."+fileExtension) if err != nil { return "", err } diff --git a/render.go b/render.go index 935c692..c2f2900 100644 --- a/render.go +++ b/render.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "html/template" - "io/ioutil" "log" "net/http" "os" @@ -186,7 +185,7 @@ func initRendering() error { }, "jsonFile": func(filename string) *map[string]interface{} { parsed := &map[string]interface{}{} - content, err := ioutil.ReadFile(filename) + content, err := os.ReadFile(filename) if err != nil { return nil } diff --git a/templateAssets.go b/templateAssets.go index 4a1ab1b..7fb467a 100644 --- a/templateAssets.go +++ b/templateAssets.go @@ -3,7 +3,6 @@ package main import ( "crypto/sha1" "fmt" - "io/ioutil" "mime" "net/http" "os" @@ -42,7 +41,7 @@ func initTemplateAssets() (err error) { } func compileAsset(name string) (string, error) { - originalContent, err := ioutil.ReadFile(name) + originalContent, err := os.ReadFile(name) if err != nil { return "", err } diff --git a/templateStrings.go b/templateStrings.go index 05e5c32..138ea25 100644 --- a/templateStrings.go +++ b/templateStrings.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "os" "path" @@ -22,7 +21,7 @@ func initTemplateStrings() error { } for _, variant := range variants { variantStrings := map[string]string{} - fileContent, err := ioutil.ReadFile(path.Join(stringsDir, variant+variantFileExt)) + fileContent, err := os.ReadFile(path.Join(stringsDir, variant+variantFileExt)) if err != nil { if os.IsNotExist(err) { continue