mirror of
https://github.com/joohoi/acme-dns.git
synced 2025-07-13 17:27:51 +07:00
Fix deprecated ioutil references
This commit is contained in:
4
api.go
4
api.go
@ -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 {
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user