fix: Replaced ioutil as it was deprecated in Golang.

This commit is contained in:
James Wells 2024-02-09 12:47:17 -08:00
parent 82a964fc50
commit 97c8af8816
Signed by: jwells
GPG key ID: 73196D10B8E65666
18 changed files with 105 additions and 114 deletions

View file

@ -3,8 +3,8 @@ package chaindb
import (
sha256 "crypto/sha256"
fmt "fmt"
ioutil "io/ioutil"
log "log"
os "os"
time "time"
gs "github.com/dragonheim/gagent/internal/gstructs"
@ -70,7 +70,7 @@ func (db *GagentDb) WriteHCL(ChainDBPath string) error {
agentBody.SetAttributeValue("version", cty.StringVal(row.Agent.Shasum))
}
return ioutil.WriteFile(ChainDBPath, f.Bytes(), 0600)
return os.WriteFile(ChainDBPath, f.Bytes(), 0600)
}
/*

View file

@ -1,10 +1,10 @@
package chaindb
import (
"bytes"
"os"
"testing"
"time"
bytes "bytes"
os "os"
testing "testing"
time "time"
gs "github.com/dragonheim/gagent/internal/gstructs"
)

View file

@ -4,7 +4,6 @@ import (
sha "crypto/sha256"
hex "encoding/hex"
fmt "fmt"
ioutil "io/ioutil"
log "log"
os "os"
regexp "regexp"
@ -34,7 +33,7 @@ func Main(wg *sync.WaitGroup, config gs.GagentConfig) {
var err error
if config.CMode {
agent.Script, err = ioutil.ReadFile(config.Agent)
agent.Script, err = os.ReadFile(config.Agent)
if err != nil {
log.Printf("[ERROR] No such file or directory: %s", config.Agent)
os.Exit(4)

View file

@ -1,13 +1,13 @@
package client
import (
"bytes"
"errors"
"io/ioutil"
"log"
"os"
"sync"
"testing"
bytes "bytes"
errors "errors"
io "io"
log "log"
os "os"
sync "sync"
testing "testing"
gs "github.com/dragonheim/gagent/internal/gstructs"
@ -107,7 +107,7 @@ func equalStringSlices(a, b []string) bool {
func TestMain(t *testing.T) {
// Prepare a temporary agent file for testing
tmpAgentFile, err := ioutil.TempFile("", "agent")
tmpAgentFile, err := io.TempFile("", "agent")
if err != nil {
t.Fatal(err)
}

View file

@ -1,7 +1,7 @@
package gstructs
import (
"fmt"
fmt "fmt"
)
type AgentStatus []string

View file

@ -1,10 +1,10 @@
package gstructs_test
import (
"testing"
testing "testing"
gs "github.com/dragonheim/gagent/internal/gstructs"
"github.com/stretchr/testify/assert"
assert "github.com/stretchr/testify/assert"
)
func TestGetByIndex(t *testing.T) {

View file

@ -1,7 +1,7 @@
package gstructs_test
import (
"testing"
testing "testing"
gs "github.com/dragonheim/gagent/internal/gstructs"
)

View file

@ -1,14 +1,14 @@
package router_test
import (
"net/http"
"net/http/httptest"
"sync"
"testing"
"time"
http "net/http"
httptest "net/http/httptest"
sync "sync"
testing "testing"
time "time"
gs "github.com/dragonheim/gagent/internal/gstructs"
"github.com/dragonheim/gagent/internal/router"
router "github.com/dragonheim/gagent/internal/router"
)
func TestRouterMain(t *testing.T) {

View file

@ -1,17 +1,17 @@
package setup_test
import (
"bytes"
"io"
"log"
"os"
"testing"
bytes "bytes"
io "io"
log "log"
os "os"
testing "testing"
"strings"
"sync"
strings "strings"
sync "sync"
gs "github.com/dragonheim/gagent/internal/gstructs"
"github.com/dragonheim/gagent/internal/setup"
setup "github.com/dragonheim/gagent/internal/setup"
)
func TestSetupMain(t *testing.T) {

View file

@ -1,18 +1,18 @@
package worker_test
import (
"bytes"
"io"
"log"
"os"
"testing"
bytes "bytes"
io "io"
log "log"
os "os"
testing "testing"
"strings"
"sync"
strings "strings"
sync "sync"
gs "github.com/dragonheim/gagent/internal/gstructs"
"github.com/dragonheim/gagent/internal/worker"
worker "github.com/dragonheim/gagent/internal/worker"
)
func TestWorkerMain(t *testing.T) {