Browse Source

Go 1.16

master
Jan-Lukas Else 2 weeks ago
parent
commit
91788efe67
12 changed files with 17 additions and 24 deletions
  1. +1
    -1
      Dockerfile
  2. +2
    -2
      activityPub.go
  3. +2
    -2
      activityPubSending.go
  4. +1
    -2
      authentication.go
  5. +1
    -2
      cache.go
  6. +1
    -2
      captcha.go
  7. +2
    -2
      go.mod
  8. +2
    -2
      go.sum
  9. +2
    -3
      micropubMedia.go
  10. +1
    -2
      render.go
  11. +1
    -2
      templateAssets.go
  12. +1
    -2
      templateStrings.go

+ 1
- 1
Dockerfile View File

@ -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/


+ 2
- 2
activityPub.go View File

@ -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
}


+ 2
- 2
activityPubSending.go View File

@ -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))
}


+ 1
- 2
authentication.go View File

@ -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


+ 1
- 2
cache.go View File

@ -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 == "" {


+ 1
- 2
captcha.go View File

@ -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


+ 2
- 2
go.mod View File

@ -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


+ 2
- 2
go.sum View File

@ -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=


+ 2
- 3
micropubMedia.go View File

@ -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
}


+ 1
- 2
render.go View File

@ -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
}


+ 1
- 2
templateAssets.go View File

@ -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
}


+ 1
- 2
templateStrings.go View File

@ -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


Loading…
Cancel
Save