From 97c8af881607d7768a448a230a2f4e1029432be9 Mon Sep 17 00:00:00 2001 From: James Wells Date: Fri, 9 Feb 2024 12:47:17 -0800 Subject: [PATCH] fix: Replaced ioutil as it was deprecated in Golang. --- README.md | 4 +- cmd/gagent/main_test.go | 7 +-- go.mod | 28 +++++----- go.sum | 65 ++++++++++------------ internal/chaindb/chaindb.go | 4 +- internal/chaindb/chaindb_test.go | 8 +-- internal/client/client.go | 3 +- internal/client/client_test.go | 16 +++--- internal/gstructs/agent_status.go | 2 +- internal/gstructs/agent_status_test.go | 4 +- internal/gstructs/gstructs_test.go | 2 +- internal/router/router_test.go | 12 ++-- internal/setup/setup_test.go | 16 +++--- internal/worker/worker_test.go | 16 +++--- pkg/picol/commands.go | 8 +-- pkg/picol/commands_test.go | 4 +- pkg/picol/picol_unused/main.go_unused | 12 ++-- pkg/picol/picol_unused/main_test.go_unused | 8 +-- 18 files changed, 105 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index ef8d670..42acc46 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # G'Agent -[![Maintained Status](https://img.shields.io/maintenance/yes/2023?style=plastic)](https://github.com/dragonheim/gagent) +[![Maintained Status](https://img.shields.io/maintenance/yes/2024?style=plastic)](https://github.com/dragonheim/gagent) [![License](https://img.shields.io/badge/License-MIT-limegreen.svg)](https://github.com/dragonheim/gagent/src/branch/main/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/dragonheim/gagent)](https://goreportcard.com/report/github.com/dragonheim/gagent) @@ -7,7 +7,7 @@ A Golang based mobile agent system loosely inspired by the [Agent Tcl / D'Agents](http://www.cs.dartmouth.edu/~dfk/agents/) system created by Robert S. Gray of Dartmouth college. -Please note that this program is mostly meant to be used as a tool for me to learn software development in Go, and is not meant to be used in a production environments. +Please note that this program is mostly meant to be used as a tool for me to learn software development in Go, and is not meant to be used in production environments. GPT-4 has been used in various parts of this project to debug, improve functionality and provide examples of how to get over various hurdles as I learn Go. diff --git a/cmd/gagent/main_test.go b/cmd/gagent/main_test.go index 25e74c1..3efdb37 100644 --- a/cmd/gagent/main_test.go +++ b/cmd/gagent/main_test.go @@ -1,9 +1,8 @@ package main import ( - "io/ioutil" - "os" - "testing" + os "os" + testing "testing" // main "github.com/dragonheim/gagent/cmd/gagent" gstructs "github.com/dragonheim/gagent/internal/gstructs" @@ -11,7 +10,7 @@ import ( // This function will create a temporary config file for testing purposes func createTestConfigFile() (string, error) { - tmpfile, err := ioutil.TempFile("", "test_config_*.hcl") + tmpfile, err := os.CreateTemp("", "test_config_*.hcl") if err != nil { return "", err } diff --git a/go.mod b/go.mod index 50c4001..a9a36dc 100644 --- a/go.mod +++ b/go.mod @@ -1,39 +1,37 @@ module github.com/dragonheim/gagent -go 1.18 +go 1.21 require ( github.com/Showmax/go-fqdn v1.0.0 github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a github.com/caarlos0/env/v6 v6.10.1 - github.com/carlmjohnson/versioninfo v0.22.4 - github.com/hashicorp/hcl/v2 v2.17.0 + github.com/carlmjohnson/versioninfo v0.22.5 + github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/logutils v1.0.0 github.com/jakehl/goid v1.1.0 github.com/pebbe/zmq4 v1.2.10 - github.com/prometheus/client_golang v1.16.0 + github.com/prometheus/client_golang v1.18.0 github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae github.com/stretchr/testify v1.8.4 - github.com/zclconf/go-cty v1.13.2 + github.com/zclconf/go-cty v1.14.2 ) require ( github.com/agext/levenshtein v1.2.3 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/kr/text v0.2.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.0 // indirect - golang.org/x/sys v0.9.0 // indirect - golang.org/x/text v0.10.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.46.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect + golang.org/x/sys v0.17.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 68be6a8..8fcadd8 100644 --- a/go.sum +++ b/go.sum @@ -2,74 +2,69 @@ github.com/Showmax/go-fqdn v1.0.0 h1:0rG5IbmVliNT5O19Mfuvna9LL7zlHyRfsSvBPZmF9tM github.com/Showmax/go-fqdn v1.0.0/go.mod h1:SfrFBzmDCtCGrnHhoDjuvFnKsWjEQX/Q9ARZvOrJAko= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a h1:YJuVATwP+Gzk7nys0U/DKjKkoYp1n/sYm0yi5vX8W8M= github.com/aviddiviner/docopt-go v0.0.0-20170807220726-d8a1d67efc6a/go.mod h1:pBRbUcGboHT5qBceq2Cg/WIcDbO78a8wPxTg8zmS3Hs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II= github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= -github.com/carlmjohnson/versioninfo v0.22.4 h1:AucUHDSKmk6j7Yx3dECGUxaowGHOAN0Zx5/EBtsXn4Y= -github.com/carlmjohnson/versioninfo v0.22.4/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= +github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc= +github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= +github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/jakehl/goid v1.1.0 h1:c08GO8z16wWJtfQhyiD8BQRFkpf1oDxaPmA+uYAG+50= github.com/jakehl/goid v1.1.0/go.mod h1:V6bQh+tr2Oay5WHL0jmTTJWrABYIO+cs4/P6e1prV1o= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/pebbe/zmq4 v1.2.10 h1:wQkqRZ3CZeABIeidr3e8uQZMMH5YAykA/WN0L5zkd1c= github.com/pebbe/zmq4 v1.2.10/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuRbyk= -github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae h1:hnJJroq/kooxO2jUKDc8KXxj8tilWvOlD0hzDDv05ss= github.com/slayer/autorestart v0.0.0-20170706172547-5ebd91f955ae/go.mod h1:p+QQKBy7tS+myk+y3sgnAKx4gUtD/Q9Z6KEd77cLzWY= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= -github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI= +github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/chaindb/chaindb.go b/internal/chaindb/chaindb.go index 3e3965a..bc15c4f 100644 --- a/internal/chaindb/chaindb.go +++ b/internal/chaindb/chaindb.go @@ -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) } /* diff --git a/internal/chaindb/chaindb_test.go b/internal/chaindb/chaindb_test.go index 8c2d980..aa838b3 100644 --- a/internal/chaindb/chaindb_test.go +++ b/internal/chaindb/chaindb_test.go @@ -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" ) diff --git a/internal/client/client.go b/internal/client/client.go index 364a352..21862e0 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -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) diff --git a/internal/client/client_test.go b/internal/client/client_test.go index 2f00858..41c4297 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -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) } diff --git a/internal/gstructs/agent_status.go b/internal/gstructs/agent_status.go index ab36540..e439bad 100644 --- a/internal/gstructs/agent_status.go +++ b/internal/gstructs/agent_status.go @@ -1,7 +1,7 @@ package gstructs import ( - "fmt" + fmt "fmt" ) type AgentStatus []string diff --git a/internal/gstructs/agent_status_test.go b/internal/gstructs/agent_status_test.go index dda29ac..afff4ff 100644 --- a/internal/gstructs/agent_status_test.go +++ b/internal/gstructs/agent_status_test.go @@ -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) { diff --git a/internal/gstructs/gstructs_test.go b/internal/gstructs/gstructs_test.go index 1bb774a..98121ed 100644 --- a/internal/gstructs/gstructs_test.go +++ b/internal/gstructs/gstructs_test.go @@ -1,7 +1,7 @@ package gstructs_test import ( - "testing" + testing "testing" gs "github.com/dragonheim/gagent/internal/gstructs" ) diff --git a/internal/router/router_test.go b/internal/router/router_test.go index 35b90c2..2b52a5e 100644 --- a/internal/router/router_test.go +++ b/internal/router/router_test.go @@ -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) { diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 37d626e..cb6da23 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -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) { diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go index e98a02f..b3188ee 100644 --- a/internal/worker/worker_test.go +++ b/internal/worker/worker_test.go @@ -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) { diff --git a/pkg/picol/commands.go b/pkg/picol/commands.go index 1c21af3..345e4be 100644 --- a/pkg/picol/commands.go +++ b/pkg/picol/commands.go @@ -1,10 +1,10 @@ package picol import ( - "errors" - "fmt" - "strconv" - "strings" + errors "errors" + fmt "fmt" + strconv "strconv" + strings "strings" ) /* diff --git a/pkg/picol/commands_test.go b/pkg/picol/commands_test.go index 66e8ed8..b166078 100644 --- a/pkg/picol/commands_test.go +++ b/pkg/picol/commands_test.go @@ -1,9 +1,9 @@ package picol_test import ( - "testing" + testing "testing" - "github.com/dragonheim/gagent/pkg/picol" + picol "github.com/dragonheim/gagent/pkg/picol" ) func Test_NeedleInHaystack(t *testing.T) { diff --git a/pkg/picol/picol_unused/main.go_unused b/pkg/picol/picol_unused/main.go_unused index 4db8dd1..954c29a 100644 --- a/pkg/picol/picol_unused/main.go_unused +++ b/pkg/picol/picol_unused/main.go_unused @@ -1,11 +1,11 @@ package main import ( - "bufio" - "flag" - "fmt" - "io/ioutil" - "os" + bufio "bufio" + flag "flag" + fmt "fmt" + io "io" + os "os" picol "github.com/dragonheim/gagent/pkg/picol" ) @@ -16,7 +16,7 @@ func RunPicol(fname string) error { interp := picol.NewInterpreter() interp.RegisterCoreCommands() - buf, err := ioutil.ReadFile(fname) + buf, err := io.ReadFile(fname) if err == nil { result, err := interp.Eval(string(buf)) if err != nil { diff --git a/pkg/picol/picol_unused/main_test.go_unused b/pkg/picol/picol_unused/main_test.go_unused index 896671d..8efd72f 100644 --- a/pkg/picol/picol_unused/main_test.go_unused +++ b/pkg/picol/picol_unused/main_test.go_unused @@ -1,9 +1,9 @@ package main_test import ( - "io/ioutil" - "os" - "testing" + io "io" + os "os" + testing "testing" picol "github.com/dragonheim/gagent/pkg/picol/picol_unused" ) @@ -11,7 +11,7 @@ import ( func Test_RunPicol(t *testing.T) { // Create a temporary test file content := []byte("set a 5\nset b 7\n+ $a $b\n") - tmpfile, err := ioutil.TempFile("", "picol_test") + tmpfile, err := io.TempFile("", "picol_test") if err != nil { t.Fatalf("Error creating temporary test file: %v", err) }