diff options
author | Moritz Poldrack <git@moritz.sh> | 2022-08-17 16:19:45 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-08-22 09:30:19 +0200 |
commit | 9cffc45f0347e5c8b801c151955fa9326b9b2ba7 (patch) | |
tree | 4de8e74f1ec7378297185f65807cb9019caf1a1a /lib | |
parent | 1b91b68e7385239783bee818974c4ce2032b7039 (diff) | |
download | aerc-9cffc45f0347e5c8b801c151955fa9326b9b2ba7.tar.gz |
go: removed io/ioutil
Since the minimum required version of Go has been bumped to 1.16, the
deprecation of io/ioutil can now be acted upon. This Commit removes the
remaining dependencies on ioutil and replaces them with their io or os
counterparts.
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crypto/gpg/gpgbin/decrypt.go | 3 | ||||
-rw-r--r-- | lib/crypto/gpg/gpgbin/verify.go | 5 | ||||
-rw-r--r-- | lib/crypto/pgp/pgp.go | 3 | ||||
-rw-r--r-- | lib/messageview.go | 3 | ||||
-rw-r--r-- | lib/parse/hyperlinks_test.go | 4 |
5 files changed, 7 insertions, 11 deletions
diff --git a/lib/crypto/gpg/gpgbin/decrypt.go b/lib/crypto/gpg/gpgbin/decrypt.go index 09626303..86d5575e 100644 --- a/lib/crypto/gpg/gpgbin/decrypt.go +++ b/lib/crypto/gpg/gpgbin/decrypt.go @@ -3,7 +3,6 @@ package gpgbin import ( "bytes" "io" - "io/ioutil" "git.sr.ht/~rjarry/aerc/models" ) @@ -12,7 +11,7 @@ import ( // the signature is also verified func Decrypt(r io.Reader) (*models.MessageDetails, error) { md := new(models.MessageDetails) - orig, err := ioutil.ReadAll(r) + orig, err := io.ReadAll(r) if err != nil { return md, err } diff --git a/lib/crypto/gpg/gpgbin/verify.go b/lib/crypto/gpg/gpgbin/verify.go index 5079a0a2..8208dc0d 100644 --- a/lib/crypto/gpg/gpgbin/verify.go +++ b/lib/crypto/gpg/gpgbin/verify.go @@ -3,7 +3,6 @@ package gpgbin import ( "bytes" "io" - "io/ioutil" "os" "git.sr.ht/~rjarry/aerc/models" @@ -15,7 +14,7 @@ func Verify(m io.Reader, s io.Reader) (*models.MessageDetails, error) { args := []string{"--verify"} if s != nil { // Detached sig, save the sig to a tmp file and send msg over stdin - sig, err := ioutil.TempFile("", "sig") + sig, err := os.CreateTemp("", "sig") if err != nil { return nil, err } @@ -24,7 +23,7 @@ func Verify(m io.Reader, s io.Reader) (*models.MessageDetails, error) { defer os.Remove(sig.Name()) args = append(args, sig.Name(), "-") } - orig, err := ioutil.ReadAll(m) + orig, err := io.ReadAll(m) if err != nil { return nil, err } diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go index 689bae3f..f5612eea 100644 --- a/lib/crypto/pgp/pgp.go +++ b/lib/crypto/pgp/pgp.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -122,7 +121,7 @@ func (m *Mail) Decrypt(r io.Reader, decryptKeys openpgp.PromptFunction) (*models if pgpReader.MessageDetails.IsSigned { // we should consume the UnverifiedBody until EOF in order // to get the correct signature data - data, err := ioutil.ReadAll(pgpReader.MessageDetails.UnverifiedBody) + data, err := io.ReadAll(pgpReader.MessageDetails.UnverifiedBody) if err != nil { return nil, err } diff --git a/lib/messageview.go b/lib/messageview.go index e0e86ea1..6ad86c9c 100644 --- a/lib/messageview.go +++ b/lib/messageview.go @@ -3,7 +3,6 @@ package lib import ( "bytes" "io" - "io/ioutil" "github.com/ProtonMail/go-crypto/openpgp" "github.com/emersion/go-message" @@ -77,7 +76,7 @@ func NewMessageStoreView(messageInfo *models.MessageInfo, cb(nil, err) return } - msv.message, err = ioutil.ReadAll(md.Body) + msv.message, err = io.ReadAll(md.Body) if err != nil { cb(nil, err) return diff --git a/lib/parse/hyperlinks_test.go b/lib/parse/hyperlinks_test.go index f16392a5..ba67664b 100644 --- a/lib/parse/hyperlinks_test.go +++ b/lib/parse/hyperlinks_test.go @@ -1,7 +1,7 @@ package parse_test import ( - "io/ioutil" + "io" "strings" "testing" @@ -75,7 +75,7 @@ func TestHyperlinks(t *testing.T) { // make sure reader is exact copy of input reader reader, links := parse.HttpLinks(strings.NewReader(test.text)) - if data, err := ioutil.ReadAll(reader); err != nil { + if data, err := io.ReadAll(reader); err != nil { t.Errorf("could not read text: %v", err) } else if string(data) != test.text { t.Errorf("did not copy input reader correctly") |