Fix deprecated ioutil references

This commit is contained in:
Joona Hoikkala 2024-12-15 12:51:28 +02:00
parent 1d69312b01
commit 2d4d0e5983
No known key found for this signature in database
GPG Key ID: 1708DAE66E87A524
3 changed files with 10 additions and 10 deletions

4
api.go
View File

@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"github.com/julienschmidt/httprouter"
@ -24,7 +24,7 @@ func webRegisterPost(w http.ResponseWriter, r *http.Request, _ httprouter.Params
var reg []byte
var err error
aTXT := ACMETxt{}
bdata, _ := ioutil.ReadAll(r.Body)
bdata, _ := io.ReadAll(r.Body)
if len(bdata) > 0 {
err = json.Unmarshal(bdata, &aTXT)
if err != nil {

View File

@ -3,12 +3,13 @@ package main
import (
"flag"
"fmt"
log "github.com/sirupsen/logrus"
logrustest "github.com/sirupsen/logrus/hooks/test"
"io/ioutil"
"io"
"os"
"sync"
"testing"
log "github.com/sirupsen/logrus"
logrustest "github.com/sirupsen/logrus/hooks/test"
)
var loghook = new(logrustest.Hook)
@ -96,7 +97,7 @@ func setupConfig() {
}
func setupTestLogger() {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
log.AddHook(loghook)
}

View File

@ -1,7 +1,6 @@
package main
import (
"io/ioutil"
"os"
"syscall"
"testing"
@ -51,7 +50,7 @@ func TestReadConfig(t *testing.T) {
DNSConfig{},
},
} {
tmpfile, err := ioutil.TempFile("", "acmedns")
tmpfile, err := os.CreateTemp("", "acmedns")
if err != nil {
t.Error("Could not create temporary file")
}
@ -99,7 +98,7 @@ func TestGetIPListFromHeader(t *testing.T) {
}
func TestFileCheckPermissionDenied(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "acmedns")
tmpfile, err := os.CreateTemp("", "acmedns")
if err != nil {
t.Error("Could not create temporary file")
}
@ -118,7 +117,7 @@ func TestFileCheckNotExists(t *testing.T) {
}
func TestFileCheckOK(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "acmedns")
tmpfile, err := os.CreateTemp("", "acmedns")
if err != nil {
t.Error("Could not create temporary file")
}