Fix deprecated ioutil references

This commit is contained in:
Joona Hoikkala
2024-12-15 12:51:28 +02:00
parent 1d69312b01
commit 2d4d0e5983
3 changed files with 10 additions and 10 deletions

4
api.go
View File

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

View File

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

View File

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