浏览代码

all: Remove usage of deprecated io/ioutil (#7971)

As of Go 1.16 io/ioutil is deprecated. This replaces usage with the
corresponding functions in package os and package io.
Jakob Borg 3 年之前
父节点
当前提交
4b750b6dc3
共有 71 个文件被更改,包括 190 次插入235 次删除
  1. 6 7
      build.go
  2. 1 2
      cmd/stcrashreceiver/main.go
  3. 2 2
      cmd/stcrashreceiver/sentry.go
  4. 2 2
      cmd/stcrashreceiver/sentry_test.go
  5. 2 2
      cmd/stcrashreceiver/sourcecodeloader.go
  6. 2 3
      cmd/stcrashreceiver/stcrashreceiver.go
  7. 2 2
      cmd/stcrashreceiver/util.go
  8. 3 4
      cmd/strelaypoolsrv/main.go
  9. 2 2
      cmd/strelaysrv/pool.go
  10. 3 4
      cmd/stsigtool/main.go
  11. 2 2
      cmd/syncthing/cli/main.go
  12. 2 2
      cmd/syncthing/cli/utils.go
  13. 1 2
      cmd/syncthing/crash_reporting.go
  14. 2 2
      cmd/syncthing/decrypt/decrypt.go
  15. 1 2
      cmd/syncthing/main.go
  16. 3 4
      cmd/syncthing/monitor_test.go
  17. 2 3
      cmd/ursrv/main.go
  18. 7 8
      lib/api/api.go
  19. 6 7
      lib/api/api_test.go
  20. 2 2
      lib/api/auto/auto_test.go
  21. 1 2
      lib/api/confighandler.go
  22. 2 3
      lib/assets/assets_test.go
  23. 1 2
      lib/config/config.go
  24. 4 5
      lib/config/config_test.go
  25. 1 2
      lib/discover/global.go
  26. 2 2
      lib/discover/global_test.go
  27. 1 2
      lib/fs/basicfs_test.go
  28. 1 2
      lib/fs/basicfs_watch_test.go
  29. 1 2
      lib/fs/fakefs.go
  30. 6 7
      lib/fs/fakefs_test.go
  31. 2 3
      lib/fs/filesystem_copy_range_test.go
  32. 8 9
      lib/fs/mtimefs_test.go
  33. 6 7
      lib/ignore/ignore_test.go
  34. 1 2
      lib/logger/logger.go
  35. 3 3
      lib/logger/logger_test.go
  36. 2 3
      lib/model/folder_sendrecv_test.go
  37. 4 5
      lib/model/model_test.go
  38. 2 3
      lib/model/requests_test.go
  39. 2 3
      lib/model/testutils_test.go
  40. 1 2
      lib/nat/structs_test.go
  41. 1 1
      lib/osutil/atomic.go
  42. 5 6
      lib/osutil/atomic_test.go
  43. 1 2
      lib/osutil/atomic_unix_test.go
  44. 4 4
      lib/osutil/osutil_test.go
  45. 2 3
      lib/osutil/traversessymlink_test.go
  46. 3 3
      lib/protocol/protocol_test.go
  47. 1 2
      lib/rc/rc.go
  48. 3 4
      lib/scanner/walk_test.go
  49. 1 2
      lib/syncthing/syncthing_test.go
  50. 2 3
      lib/syncthing/utils.go
  51. 3 4
      lib/upgrade/upgrade_supported.go
  52. 2 2
      lib/upnp/upnp.go
  53. 1 2
      lib/versioner/external_test.go
  54. 2 2
      lib/versioner/simple_test.go
  55. 3 3
      lib/versioner/staggered_test.go
  56. 5 4
      lib/versioner/trashcan_test.go
  57. 1 2
      lib/versioner/versioner_test.go
  58. 1 2
      lib/weakhash/weakhash_test.go
  59. 3 3
      script/authors.go
  60. 1 2
      script/commit-msg.go
  61. 1 2
      script/genassets.go
  62. 1 2
      script/prune_mocks.go
  63. 2 2
      script/transifexdl.go
  64. 15 16
      test/conflict_test.go
  65. 2 2
      test/delay_scan_test.go
  66. 5 4
      test/http_test.go
  67. 2 3
      test/ignore_test.go
  68. 8 8
      test/override_test.go
  69. 2 2
      test/parallell_scan_test.go
  70. 1 2
      test/reset_test.go
  71. 2 3
      test/util.go

+ 6 - 7
build.go

@@ -20,7 +20,6 @@ import (
 	"flag"
 	"flag"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"os/exec"
 	"os/exec"
@@ -723,7 +722,7 @@ func shouldBuildSyso(dir string) (string, error) {
 	}
 	}
 
 
 	jsonPath := filepath.Join(dir, "versioninfo.json")
 	jsonPath := filepath.Join(dir, "versioninfo.json")
-	err = ioutil.WriteFile(jsonPath, bs, 0644)
+	err = os.WriteFile(jsonPath, bs, 0644)
 	if err != nil {
 	if err != nil {
 		return "", errors.New("failed to create " + jsonPath + ": " + err.Error())
 		return "", errors.New("failed to create " + jsonPath + ": " + err.Error())
 	}
 	}
@@ -762,12 +761,12 @@ func shouldCleanupSyso(sysoFilePath string) {
 // exists. The permission bits are copied as well. If dst already exists and
 // exists. The permission bits are copied as well. If dst already exists and
 // the contents are identical to src the modification time is not updated.
 // the contents are identical to src the modification time is not updated.
 func copyFile(src, dst string, perm os.FileMode) error {
 func copyFile(src, dst string, perm os.FileMode) error {
-	in, err := ioutil.ReadFile(src)
+	in, err := os.ReadFile(src)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
 
 
-	out, err := ioutil.ReadFile(dst)
+	out, err := os.ReadFile(dst)
 	if err != nil {
 	if err != nil {
 		// The destination probably doesn't exist, we should create
 		// The destination probably doesn't exist, we should create
 		// it.
 		// it.
@@ -783,7 +782,7 @@ func copyFile(src, dst string, perm os.FileMode) error {
 
 
 copy:
 copy:
 	os.MkdirAll(filepath.Dir(dst), 0777)
 	os.MkdirAll(filepath.Dir(dst), 0777)
-	if err := ioutil.WriteFile(dst, in, perm); err != nil {
+	if err := os.WriteFile(dst, in, perm); err != nil {
 		return err
 		return err
 	}
 	}
 
 
@@ -958,7 +957,7 @@ func rmr(paths ...string) {
 }
 }
 
 
 func getReleaseVersion() (string, error) {
 func getReleaseVersion() (string, error) {
-	bs, err := ioutil.ReadFile("RELEASE")
+	bs, err := os.ReadFile("RELEASE")
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
 	}
 	}
@@ -1290,7 +1289,7 @@ func zipFile(out string, files []archiveFile) {
 
 
 		if strings.HasSuffix(f.dst, ".txt") {
 		if strings.HasSuffix(f.dst, ".txt") {
 			// Text file. Read it and convert line endings.
 			// Text file. Read it and convert line endings.
-			bs, err := ioutil.ReadAll(sf)
+			bs, err := io.ReadAll(sf)
 			if err != nil {
 			if err != nil {
 				log.Fatal(err)
 				log.Fatal(err)
 			}
 			}

+ 1 - 2
cmd/stcrashreceiver/main.go

@@ -17,7 +17,6 @@ import (
 	"flag"
 	"flag"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -58,7 +57,7 @@ func main() {
 func handleFailureFn(dsn, failureDir string) func(w http.ResponseWriter, req *http.Request) {
 func handleFailureFn(dsn, failureDir string) func(w http.ResponseWriter, req *http.Request) {
 	return func(w http.ResponseWriter, req *http.Request) {
 	return func(w http.ResponseWriter, req *http.Request) {
 		lr := io.LimitReader(req.Body, maxRequestSize)
 		lr := io.LimitReader(req.Body, maxRequestSize)
-		bs, err := ioutil.ReadAll(lr)
+		bs, err := io.ReadAll(lr)
 		req.Body.Close()
 		req.Body.Close()
 		if err != nil {
 		if err != nil {
 			http.Error(w, err.Error(), 500)
 			http.Error(w, err.Error(), 500)

+ 2 - 2
cmd/stcrashreceiver/sentry.go

@@ -9,7 +9,7 @@ package main
 import (
 import (
 	"bytes"
 	"bytes"
 	"errors"
 	"errors"
-	"io/ioutil"
+	"io"
 	"regexp"
 	"regexp"
 	"strings"
 	"strings"
 	"sync"
 	"sync"
@@ -93,7 +93,7 @@ func parseCrashReport(path string, report []byte) (*raven.Packet, error) {
 	}
 	}
 
 
 	r := bytes.NewReader(report)
 	r := bytes.NewReader(report)
-	ctx, err := stack.ParseDump(r, ioutil.Discard, false)
+	ctx, err := stack.ParseDump(r, io.Discard, false)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 2 - 2
cmd/stcrashreceiver/sentry_test.go

@@ -8,7 +8,7 @@ package main
 
 
 import (
 import (
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"os"
 	"testing"
 	"testing"
 )
 )
 
 
@@ -59,7 +59,7 @@ func TestParseVersion(t *testing.T) {
 }
 }
 
 
 func TestParseReport(t *testing.T) {
 func TestParseReport(t *testing.T) {
-	bs, err := ioutil.ReadFile("_testdata/panic.log")
+	bs, err := os.ReadFile("_testdata/panic.log")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 2 - 2
cmd/stcrashreceiver/sourcecodeloader.go

@@ -9,7 +9,7 @@ package main
 import (
 import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/http"
 	"path/filepath"
 	"path/filepath"
 	"strings"
 	"strings"
@@ -80,7 +80,7 @@ func (l *githubSourceCodeLoader) Load(filename string, line, context int) ([][]b
 			fmt.Println("Loading source:", resp.Status)
 			fmt.Println("Loading source:", resp.Status)
 			return nil, 0
 			return nil, 0
 		}
 		}
-		data, err := ioutil.ReadAll(resp.Body)
+		data, err := io.ReadAll(resp.Body)
 		_ = resp.Body.Close()
 		_ = resp.Body.Close()
 		if err != nil {
 		if err != nil {
 			fmt.Println("Loading source:", err.Error())
 			fmt.Println("Loading source:", err.Error())

+ 2 - 3
cmd/stcrashreceiver/stcrashreceiver.go

@@ -10,7 +10,6 @@ import (
 	"bytes"
 	"bytes"
 	"compress/gzip"
 	"compress/gzip"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -96,7 +95,7 @@ func (r *crashReceiver) servePut(reportID, fullPath string, w http.ResponseWrite
 	// Read at most maxRequestSize of report data.
 	// Read at most maxRequestSize of report data.
 	log.Println("Receiving report", reportID)
 	log.Println("Receiving report", reportID)
 	lr := io.LimitReader(req.Body, maxRequestSize)
 	lr := io.LimitReader(req.Body, maxRequestSize)
-	bs, err := ioutil.ReadAll(lr)
+	bs, err := io.ReadAll(lr)
 	if err != nil {
 	if err != nil {
 		log.Println("Reading report:", err)
 		log.Println("Reading report:", err)
 		http.Error(w, "Internal server error", http.StatusInternalServerError)
 		http.Error(w, "Internal server error", http.StatusInternalServerError)
@@ -110,7 +109,7 @@ func (r *crashReceiver) servePut(reportID, fullPath string, w http.ResponseWrite
 	gw.Close()
 	gw.Close()
 
 
 	// Create an output file with the compressed report
 	// Create an output file with the compressed report
-	err = ioutil.WriteFile(fullPath, buf.Bytes(), 0644)
+	err = os.WriteFile(fullPath, buf.Bytes(), 0644)
 	if err != nil {
 	if err != nil {
 		log.Println("Saving report:", err)
 		log.Println("Saving report:", err)
 		http.Error(w, "Internal server error", http.StatusInternalServerError)
 		http.Error(w, "Internal server error", http.StatusInternalServerError)

+ 2 - 2
cmd/stcrashreceiver/util.go

@@ -10,9 +10,9 @@ import (
 	"bytes"
 	"bytes"
 	"compress/gzip"
 	"compress/gzip"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
+	"os"
 	"path/filepath"
 	"path/filepath"
 	"time"
 	"time"
 
 
@@ -53,5 +53,5 @@ func compressAndWrite(bs []byte, fullPath string) error {
 	gw.Close()
 	gw.Close()
 
 
 	// Create an output file with the compressed report
 	// Create an output file with the compressed report
-	return ioutil.WriteFile(fullPath, buf.Bytes(), 0644)
+	return os.WriteFile(fullPath, buf.Bytes(), 0644)
 }
 }

+ 3 - 4
cmd/strelaypoolsrv/main.go

@@ -11,7 +11,6 @@ import (
 	"flag"
 	"flag"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
@@ -560,7 +559,7 @@ func limit(addr string, cache *lru.Cache, lock sync.Mutex, intv time.Duration, b
 }
 }
 
 
 func loadRelays(file string) []*relay {
 func loadRelays(file string) []*relay {
-	content, err := ioutil.ReadFile(file)
+	content, err := os.ReadFile(file)
 	if err != nil {
 	if err != nil {
 		log.Println("Failed to load relays: " + err.Error())
 		log.Println("Failed to load relays: " + err.Error())
 		return nil
 		return nil
@@ -598,11 +597,11 @@ func saveRelays(file string, relays []*relay) error {
 	for _, relay := range relays {
 	for _, relay := range relays {
 		content += relay.uri.String() + "\n"
 		content += relay.uri.String() + "\n"
 	}
 	}
-	return ioutil.WriteFile(file, []byte(content), 0777)
+	return os.WriteFile(file, []byte(content), 0777)
 }
 }
 
 
 func createTestCertificate() tls.Certificate {
 func createTestCertificate() tls.Certificate {
-	tmpDir, err := ioutil.TempDir("", "relaypoolsrv")
+	tmpDir, err := os.MkdirTemp("", "relaypoolsrv")
 	if err != nil {
 	if err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}

+ 2 - 2
cmd/strelaysrv/pool.go

@@ -6,7 +6,7 @@ import (
 	"bytes"
 	"bytes"
 	"crypto/tls"
 	"crypto/tls"
 	"encoding/json"
 	"encoding/json"
-	"io/ioutil"
+	"io"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
@@ -56,7 +56,7 @@ func poolHandler(pool string, uri *url.URL, mapping mapping, ownCert tls.Certifi
 			continue
 			continue
 		}
 		}
 
 
-		bs, err := ioutil.ReadAll(resp.Body)
+		bs, err := io.ReadAll(resp.Body)
 		resp.Body.Close()
 		resp.Body.Close()
 		if err != nil {
 		if err != nil {
 			log.Printf("Error joining pool %v: reading response: %v", pool, err)
 			log.Printf("Error joining pool %v: reading response: %v", pool, err)

+ 3 - 4
cmd/stsigtool/main.go

@@ -9,7 +9,6 @@ package main
 import (
 import (
 	"flag"
 	"flag"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 
 
@@ -69,7 +68,7 @@ func gen() {
 }
 }
 
 
 func sign(keyname, dataname string) {
 func sign(keyname, dataname string) {
-	privkey, err := ioutil.ReadFile(keyname)
+	privkey, err := os.ReadFile(keyname)
 	if err != nil {
 	if err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}
@@ -95,7 +94,7 @@ func sign(keyname, dataname string) {
 }
 }
 
 
 func verifyWithFile(signame, dataname, keyname string) {
 func verifyWithFile(signame, dataname, keyname string) {
-	pubkey, err := ioutil.ReadFile(keyname)
+	pubkey, err := os.ReadFile(keyname)
 	if err != nil {
 	if err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}
@@ -103,7 +102,7 @@ func verifyWithFile(signame, dataname, keyname string) {
 }
 }
 
 
 func verifyWithKey(signame, dataname string, pubkey []byte) {
 func verifyWithKey(signame, dataname string, pubkey []byte) {
-	sig, err := ioutil.ReadFile(signame)
+	sig, err := os.ReadFile(signame)
 	if err != nil {
 	if err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}

+ 2 - 2
cmd/syncthing/cli/main.go

@@ -9,7 +9,7 @@ package cli
 import (
 import (
 	"bufio"
 	"bufio"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"os"
 	"os"
 	"strings"
 	"strings"
 
 
@@ -151,7 +151,7 @@ func parseFlags(c *preCli) error {
 		}
 		}
 	}
 	}
 	// We don't want kong to print anything nor os.Exit (e.g. on -h)
 	// We don't want kong to print anything nor os.Exit (e.g. on -h)
-	parser, err := kong.New(c, kong.Writers(ioutil.Discard, ioutil.Discard), kong.Exit(func(int) {}))
+	parser, err := kong.New(c, kong.Writers(io.Discard, io.Discard), kong.Exit(func(int) {}))
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 2 - 2
cmd/syncthing/cli/utils.go

@@ -10,7 +10,7 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"mime"
 	"mime"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -23,7 +23,7 @@ import (
 )
 )
 
 
 func responseToBArray(response *http.Response) ([]byte, error) {
 func responseToBArray(response *http.Response) ([]byte, error) {
-	bytes, err := ioutil.ReadAll(response.Body)
+	bytes, err := io.ReadAll(response.Body)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 1 - 2
cmd/syncthing/crash_reporting.go

@@ -10,7 +10,6 @@ import (
 	"bytes"
 	"bytes"
 	"context"
 	"context"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -62,7 +61,7 @@ func uploadPanicLogs(ctx context.Context, urlBase, dir string) {
 // the log contents. A HEAD request is made to see if the log has already
 // the log contents. A HEAD request is made to see if the log has already
 // been reported. If not, a PUT is made with the log contents.
 // been reported. If not, a PUT is made with the log contents.
 func uploadPanicLog(ctx context.Context, urlBase, file string) error {
 func uploadPanicLog(ctx context.Context, urlBase, file string) error {
-	data, err := ioutil.ReadFile(file)
+	data, err := os.ReadFile(file)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 2 - 2
cmd/syncthing/decrypt/decrypt.go

@@ -12,8 +12,8 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
+	"os"
 	"path/filepath"
 	"path/filepath"
 
 
 	"github.com/syncthing/syncthing/lib/config"
 	"github.com/syncthing/syncthing/lib/config"
@@ -112,7 +112,7 @@ func (c *CLI) withContinue(err error) error {
 // error.
 // error.
 func (c *CLI) getFolderID() (string, error) {
 func (c *CLI) getFolderID() (string, error) {
 	tokenPath := filepath.Join(c.Path, c.TokenPath)
 	tokenPath := filepath.Join(c.Path, c.TokenPath)
-	bs, err := ioutil.ReadFile(tokenPath)
+	bs, err := os.ReadFile(tokenPath)
 	if err != nil {
 	if err != nil {
 		return "", fmt.Errorf("reading folder token: %w", err)
 		return "", fmt.Errorf("reading folder token: %w", err)
 	}
 	}

+ 1 - 2
cmd/syncthing/main.go

@@ -12,7 +12,6 @@ import (
 	"crypto/tls"
 	"crypto/tls"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	_ "net/http/pprof" // Need to import this to support STPROFILER.
 	_ "net/http/pprof" // Need to import this to support STPROFILER.
@@ -500,7 +499,7 @@ func upgradeViaRest() error {
 		return err
 		return err
 	}
 	}
 	if resp.StatusCode != 200 {
 	if resp.StatusCode != 200 {
-		bs, err := ioutil.ReadAll(resp.Body)
+		bs, err := io.ReadAll(resp.Body)
 		defer resp.Body.Close()
 		defer resp.Body.Close()
 		if err != nil {
 		if err != nil {
 			return err
 			return err

+ 3 - 4
cmd/syncthing/monitor_test.go

@@ -8,7 +8,6 @@ package main
 
 
 import (
 import (
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"testing"
 	"testing"
@@ -18,7 +17,7 @@ import (
 func TestRotatedFile(t *testing.T) {
 func TestRotatedFile(t *testing.T) {
 	// Verify that log rotation happens.
 	// Verify that log rotation happens.
 
 
-	dir, err := ioutil.TempDir("", "syncthing")
+	dir, err := os.MkdirTemp("", "syncthing")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -179,7 +178,7 @@ func TestAutoClosedFile(t *testing.T) {
 	}
 	}
 
 
 	// The file should have both writes in it.
 	// The file should have both writes in it.
-	bs, err := ioutil.ReadFile(file)
+	bs, err := os.ReadFile(file)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -199,7 +198,7 @@ func TestAutoClosedFile(t *testing.T) {
 	}
 	}
 
 
 	// It should now contain three writes, as the file is always opened for appending
 	// It should now contain three writes, as the file is always opened for appending
-	bs, err = ioutil.ReadFile(file)
+	bs, err = os.ReadFile(file)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 2 - 3
cmd/ursrv/main.go

@@ -13,7 +13,6 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"html/template"
 	"html/template"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
@@ -162,7 +161,7 @@ func main() {
 	if err != nil {
 	if err != nil {
 		log.Fatalln("template:", err)
 		log.Fatalln("template:", err)
 	}
 	}
-	bs, err := ioutil.ReadAll(fd)
+	bs, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		log.Fatalln("template:", err)
 		log.Fatalln("template:", err)
 	}
 	}
@@ -324,7 +323,7 @@ func newDataHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) {
 	rep.Address = addr
 	rep.Address = addr
 
 
 	lr := &io.LimitedReader{R: r.Body, N: 40 * 1024}
 	lr := &io.LimitedReader{R: r.Body, N: 40 * 1024}
-	bs, _ := ioutil.ReadAll(lr)
+	bs, _ := io.ReadAll(lr)
 	if err := json.Unmarshal(bs, &rep); err != nil {
 	if err := json.Unmarshal(bs, &rep); err != nil {
 		log.Println("decode:", err)
 		log.Println("decode:", err)
 		if debug {
 		if debug {

+ 7 - 8
lib/api/api.go

@@ -15,7 +15,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
@@ -382,7 +381,7 @@ func (s *service) Serve(ctx context.Context) error {
 		ReadTimeout: 15 * time.Second,
 		ReadTimeout: 15 * time.Second,
 		// Prevent the HTTP server from logging stuff on its own. The things we
 		// Prevent the HTTP server from logging stuff on its own. The things we
 		// care about we log ourselves from the handlers.
 		// care about we log ourselves from the handlers.
-		ErrorLog: log.New(ioutil.Discard, "", 0),
+		ErrorLog: log.New(io.Discard, "", 0),
 	}
 	}
 
 
 	l.Infoln("GUI and API listening on", listener.Addr())
 	l.Infoln("GUI and API listening on", listener.Addr())
@@ -1098,7 +1097,7 @@ func (s *service) getSystemError(w http.ResponseWriter, r *http.Request) {
 }
 }
 
 
 func (s *service) postSystemError(w http.ResponseWriter, r *http.Request) {
 func (s *service) postSystemError(w http.ResponseWriter, r *http.Request) {
-	bs, _ := ioutil.ReadAll(r.Body)
+	bs, _ := io.ReadAll(r.Body)
 	r.Body.Close()
 	r.Body.Close()
 	l.Warnln(string(bs))
 	l.Warnln(string(bs))
 }
 }
@@ -1165,7 +1164,7 @@ func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) {
 	// Panic files
 	// Panic files
 	if panicFiles, err := filepath.Glob(filepath.Join(locations.GetBaseDir(locations.ConfigBaseDir), "panic*")); err == nil {
 	if panicFiles, err := filepath.Glob(filepath.Join(locations.GetBaseDir(locations.ConfigBaseDir), "panic*")); err == nil {
 		for _, f := range panicFiles {
 		for _, f := range panicFiles {
-			if panicFile, err := ioutil.ReadFile(f); err != nil {
+			if panicFile, err := os.ReadFile(f); err != nil {
 				l.Warnf("Support bundle: failed to load %s: %s", filepath.Base(f), err)
 				l.Warnf("Support bundle: failed to load %s: %s", filepath.Base(f), err)
 			} else {
 			} else {
 				files = append(files, fileEntry{name: filepath.Base(f), data: panicFile})
 				files = append(files, fileEntry{name: filepath.Base(f), data: panicFile})
@@ -1174,7 +1173,7 @@ func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) {
 	}
 	}
 
 
 	// Archived log (default on Windows)
 	// Archived log (default on Windows)
-	if logFile, err := ioutil.ReadFile(locations.Get(locations.LogFile)); err == nil {
+	if logFile, err := os.ReadFile(locations.Get(locations.LogFile)); err == nil {
 		files = append(files, fileEntry{name: "log-ondisk.txt", data: logFile})
 		files = append(files, fileEntry{name: "log-ondisk.txt", data: logFile})
 	}
 	}
 
 
@@ -1233,7 +1232,7 @@ func (s *service) getSupportBundle(w http.ResponseWriter, r *http.Request) {
 	zipFilePath := filepath.Join(locations.GetBaseDir(locations.ConfigBaseDir), zipFileName)
 	zipFilePath := filepath.Join(locations.GetBaseDir(locations.ConfigBaseDir), zipFileName)
 
 
 	// Write buffer zip to local zip file (back up)
 	// Write buffer zip to local zip file (back up)
-	if err := ioutil.WriteFile(zipFilePath, zipFilesBuffer.Bytes(), 0600); err != nil {
+	if err := os.WriteFile(zipFilePath, zipFilesBuffer.Bytes(), 0600); err != nil {
 		l.Warnln("Support bundle: support bundle zip could not be created:", err)
 		l.Warnln("Support bundle: support bundle zip could not be created:", err)
 	}
 	}
 
 
@@ -1323,7 +1322,7 @@ func (s *service) getDBIgnores(w http.ResponseWriter, r *http.Request) {
 func (s *service) postDBIgnores(w http.ResponseWriter, r *http.Request) {
 func (s *service) postDBIgnores(w http.ResponseWriter, r *http.Request) {
 	qs := r.URL.Query()
 	qs := r.URL.Query()
 
 
-	bs, err := ioutil.ReadAll(r.Body)
+	bs, err := io.ReadAll(r.Body)
 	r.Body.Close()
 	r.Body.Close()
 	if err != nil {
 	if err != nil {
 		http.Error(w, err.Error(), 500)
 		http.Error(w, err.Error(), 500)
@@ -1614,7 +1613,7 @@ func (s *service) getFolderVersions(w http.ResponseWriter, r *http.Request) {
 func (s *service) postFolderVersionsRestore(w http.ResponseWriter, r *http.Request) {
 func (s *service) postFolderVersionsRestore(w http.ResponseWriter, r *http.Request) {
 	qs := r.URL.Query()
 	qs := r.URL.Query()
 
 
-	bs, err := ioutil.ReadAll(r.Body)
+	bs, err := io.ReadAll(r.Body)
 	r.Body.Close()
 	r.Body.Close()
 	if err != nil {
 	if err != nil {
 		http.Error(w, err.Error(), 500)
 		http.Error(w, err.Error(), 500)

+ 6 - 7
lib/api/api_test.go

@@ -13,7 +13,6 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"net/http/httptest"
 	"net/http/httptest"
@@ -223,7 +222,7 @@ func expectURLToContain(t *testing.T, url, exp string) {
 		return
 		return
 	}
 	}
 
 
-	data, err := ioutil.ReadAll(res.Body)
+	data, err := io.ReadAll(res.Body)
 	res.Body.Close()
 	res.Body.Close()
 	if err != nil {
 	if err != nil {
 		t.Error(err)
 		t.Error(err)
@@ -508,7 +507,7 @@ func testHTTPRequest(t *testing.T, baseURL string, tc httpTestCase, apikey strin
 		return
 		return
 	}
 	}
 
 
-	data, err := ioutil.ReadAll(resp.Body)
+	data, err := io.ReadAll(resp.Body)
 	if err != nil {
 	if err != nil {
 		t.Errorf("Unexpected error reading %s: %v", tc.URL, err)
 		t.Errorf("Unexpected error reading %s: %v", tc.URL, err)
 		return
 		return
@@ -1137,7 +1136,7 @@ func TestBrowse(t *testing.T) {
 
 
 	pathSep := string(os.PathSeparator)
 	pathSep := string(os.PathSeparator)
 
 
-	tmpDir, err := ioutil.TempDir("", "syncthing")
+	tmpDir, err := os.MkdirTemp("", "syncthing")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -1146,7 +1145,7 @@ func TestBrowse(t *testing.T) {
 	if err := os.Mkdir(filepath.Join(tmpDir, "dir"), 0755); err != nil {
 	if err := os.Mkdir(filepath.Join(tmpDir, "dir"), 0755); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	if err := ioutil.WriteFile(filepath.Join(tmpDir, "file"), []byte("hello"), 0644); err != nil {
+	if err := os.WriteFile(filepath.Join(tmpDir, "file"), []byte("hello"), 0644); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	if err := os.Mkdir(filepath.Join(tmpDir, "MiXEDCase"), 0755); err != nil {
 	if err := os.Mkdir(filepath.Join(tmpDir, "MiXEDCase"), 0755); err != nil {
@@ -1251,7 +1250,7 @@ func TestConfigChanges(t *testing.T) {
 			APIKey:     testAPIKey,
 			APIKey:     testAPIKey,
 		},
 		},
 	}
 	}
-	tmpFile, err := ioutil.TempFile("", "syncthing-testConfig-")
+	tmpFile, err := os.CreateTemp("", "syncthing-testConfig-")
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}
@@ -1393,7 +1392,7 @@ func runningInContainer() bool {
 		return false
 		return false
 	}
 	}
 
 
-	bs, err := ioutil.ReadFile("/proc/1/cgroup")
+	bs, err := os.ReadFile("/proc/1/cgroup")
 	if err != nil {
 	if err != nil {
 		return false
 		return false
 	}
 	}

+ 2 - 2
lib/api/auto/auto_test.go

@@ -9,7 +9,7 @@ package auto_test
 import (
 import (
 	"bytes"
 	"bytes"
 	"compress/gzip"
 	"compress/gzip"
-	"io/ioutil"
+	"io"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
 
 
@@ -28,7 +28,7 @@ func TestAssets(t *testing.T) {
 
 
 	var gr *gzip.Reader
 	var gr *gzip.Reader
 	gr, _ = gzip.NewReader(strings.NewReader(idx.Content))
 	gr, _ = gzip.NewReader(strings.NewReader(idx.Content))
-	html, _ := ioutil.ReadAll(gr)
+	html, _ := io.ReadAll(gr)
 
 
 	if !bytes.Contains(html, []byte("<html")) {
 	if !bytes.Contains(html, []byte("<html")) {
 		t.Fatal("No html in index.html")
 		t.Fatal("No html in index.html")

+ 1 - 2
lib/api/confighandler.go

@@ -9,7 +9,6 @@ package api
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"io"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 
 
 	"github.com/julienschmidt/httprouter"
 	"github.com/julienschmidt/httprouter"
@@ -407,7 +406,7 @@ func (c *configMuxBuilder) adjustLDAP(w http.ResponseWriter, r *http.Request, ld
 
 
 // Unmarshals the content of the given body and stores it in to (i.e. to must be a pointer).
 // Unmarshals the content of the given body and stores it in to (i.e. to must be a pointer).
 func unmarshalTo(body io.ReadCloser, to interface{}) error {
 func unmarshalTo(body io.ReadCloser, to interface{}) error {
-	bs, err := ioutil.ReadAll(body)
+	bs, err := io.ReadAll(body)
 	body.Close()
 	body.Close()
 	if err != nil {
 	if err != nil {
 		return err
 		return err

+ 2 - 3
lib/assets/assets_test.go

@@ -10,7 +10,6 @@ import (
 	"bytes"
 	"bytes"
 	"compress/gzip"
 	"compress/gzip"
 	"io"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 	"net/http/httptest"
 	"net/http/httptest"
 	"strconv"
 	"strconv"
@@ -31,7 +30,7 @@ func compress(s string) string {
 func decompress(p []byte) (out []byte) {
 func decompress(p []byte) (out []byte) {
 	r, err := gzip.NewReader(bytes.NewBuffer(p))
 	r, err := gzip.NewReader(bytes.NewBuffer(p))
 	if err == nil {
 	if err == nil {
-		out, err = ioutil.ReadAll(r)
+		out, err = io.ReadAll(r)
 	}
 	}
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
@@ -81,7 +80,7 @@ func testServe(t *testing.T, gzip bool) {
 			t.Errorf("unexpected ETag %q", etag)
 			t.Errorf("unexpected ETag %q", etag)
 		}
 		}
 
 
-		body, _ := ioutil.ReadAll(res.Body)
+		body, _ := io.ReadAll(res.Body)
 
 
 		// Content-Length is the number of bytes in the encoded (compressed) body
 		// Content-Length is the number of bytes in the encoded (compressed) body
 		// (https://stackoverflow.com/a/3819303).
 		// (https://stackoverflow.com/a/3819303).

+ 1 - 2
lib/config/config.go

@@ -12,7 +12,6 @@ import (
 	"encoding/xml"
 	"encoding/xml"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"net"
 	"net"
 	"net/url"
 	"net/url"
 	"os"
 	"os"
@@ -163,7 +162,7 @@ func ReadXML(r io.Reader, myID protocol.DeviceID) (Configuration, int, error) {
 }
 }
 
 
 func ReadJSON(r io.Reader, myID protocol.DeviceID) (Configuration, error) {
 func ReadJSON(r io.Reader, myID protocol.DeviceID) (Configuration, error) {
-	bs, err := ioutil.ReadAll(r)
+	bs, err := io.ReadAll(r)
 	if err != nil {
 	if err != nil {
 		return Configuration{}, err
 		return Configuration{}, err
 	}
 	}

+ 4 - 5
lib/config/config_test.go

@@ -13,7 +13,6 @@ import (
 	"encoding/xml"
 	"encoding/xml"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"reflect"
 	"reflect"
@@ -502,7 +501,7 @@ func TestFolderPath(t *testing.T) {
 }
 }
 
 
 func TestFolderCheckPath(t *testing.T) {
 func TestFolderCheckPath(t *testing.T) {
-	n, err := ioutil.TempDir("", "")
+	n, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -643,8 +642,8 @@ func TestCopy(t *testing.T) {
 		t.Error("Config should have changed")
 		t.Error("Config should have changed")
 	}
 	}
 	if !bytes.Equal(bsOrig, bsCopy) {
 	if !bytes.Equal(bsOrig, bsCopy) {
-		// ioutil.WriteFile("a", bsOrig, 0644)
-		// ioutil.WriteFile("b", bsCopy, 0644)
+		// os.WriteFile("a", bsOrig, 0644)
+		// os.WriteFile("b", bsCopy, 0644)
 		t.Error("Copy should be unchanged")
 		t.Error("Copy should be unchanged")
 	}
 	}
 }
 }
@@ -1266,7 +1265,7 @@ func copyToTmp(path string) (string, error) {
 		return "", err
 		return "", err
 	}
 	}
 	defer orig.Close()
 	defer orig.Close()
-	temp, err := ioutil.TempFile("", "syncthing-configTest-")
+	temp, err := os.CreateTemp("", "syncthing-configTest-")
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
 	}
 	}

+ 1 - 2
lib/discover/global.go

@@ -14,7 +14,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
 	"strconv"
 	"strconv"
@@ -173,7 +172,7 @@ func (c *globalClient) Lookup(ctx context.Context, device protocol.DeviceID) (ad
 		return nil, err
 		return nil, err
 	}
 	}
 
 
-	bs, err := ioutil.ReadAll(resp.Body)
+	bs, err := io.ReadAll(resp.Body)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 2 - 2
lib/discover/global_test.go

@@ -9,7 +9,7 @@ package discover
 import (
 import (
 	"context"
 	"context"
 	"crypto/tls"
 	"crypto/tls"
-	"io/ioutil"
+	"io"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"strings"
 	"strings"
@@ -232,7 +232,7 @@ func (s *fakeDiscoveryServer) handler(w http.ResponseWriter, r *http.Request) {
 	}
 	}
 
 
 	if r.Method == "POST" {
 	if r.Method == "POST" {
-		s.announce, _ = ioutil.ReadAll(r.Body)
+		s.announce, _ = io.ReadAll(r.Body)
 		w.WriteHeader(204)
 		w.WriteHeader(204)
 	} else {
 	} else {
 		w.Header().Set("Content-Type", "application/json")
 		w.Header().Set("Content-Type", "application/json")

+ 1 - 2
lib/fs/basicfs_test.go

@@ -7,7 +7,6 @@
 package fs
 package fs
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -21,7 +20,7 @@ import (
 
 
 func setup(t *testing.T) (*BasicFilesystem, string) {
 func setup(t *testing.T) (*BasicFilesystem, string) {
 	t.Helper()
 	t.Helper()
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 2
lib/fs/basicfs_watch_test.go

@@ -13,7 +13,6 @@ import (
 	"context"
 	"context"
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -530,7 +529,7 @@ func renameTestFile(name string, old string, new string) {
 func modifyTestFile(name string, file string, content string) {
 func modifyTestFile(name string, file string, content string) {
 	joined := filepath.Join(testDirAbs, name, file)
 	joined := filepath.Join(testDirAbs, name, file)
 
 
-	err := ioutil.WriteFile(joined, []byte(content), 0755)
+	err := os.WriteFile(joined, []byte(content), 0755)
 	if err != nil {
 	if err != nil {
 		panic(fmt.Sprintf("Failed to modify test file %s: %s", joined, err))
 		panic(fmt.Sprintf("Failed to modify test file %s: %s", joined, err))
 	}
 	}

+ 1 - 2
lib/fs/fakefs.go

@@ -12,7 +12,6 @@ import (
 	"fmt"
 	"fmt"
 	"hash/fnv"
 	"hash/fnv"
 	"io"
 	"io"
-	"io/ioutil"
 	"math/rand"
 	"math/rand"
 	"net/url"
 	"net/url"
 	"os"
 	"os"
@@ -787,7 +786,7 @@ func (f *fakeFile) readShortAt(p []byte, offs int64) (int, error) {
 		diff := offs - minOffs
 		diff := offs - minOffs
 		if diff > 0 {
 		if diff > 0 {
 			lr := io.LimitReader(f.rng, diff)
 			lr := io.LimitReader(f.rng, diff)
-			io.Copy(ioutil.Discard, lr)
+			io.Copy(io.Discard, lr)
 		}
 		}
 
 
 		f.offset = offs
 		f.offset = offs

+ 6 - 7
lib/fs/fakefs_test.go

@@ -10,7 +10,6 @@ import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path"
 	"path"
 	"path/filepath"
 	"path/filepath"
@@ -88,7 +87,7 @@ func TestFakeFS(t *testing.T) {
 	}
 	}
 
 
 	// Read
 	// Read
-	bs0, err := ioutil.ReadAll(fd)
+	bs0, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -101,7 +100,7 @@ func TestFakeFS(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs1, err := ioutil.ReadAll(fd)
+	bs1, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -139,7 +138,7 @@ func testFakeFSRead(t *testing.T, fs Filesystem) {
 
 
 	// Read
 	// Read
 	fd.Seek(0, io.SeekStart)
 	fd.Seek(0, io.SeekStart)
-	bs0, err := ioutil.ReadAll(fd)
+	bs0, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -154,7 +153,7 @@ func testFakeFSRead(t *testing.T, fs Filesystem) {
 	if n != len(buf0) {
 	if n != len(buf0) {
 		t.Fatal("short read")
 		t.Fatal("short read")
 	}
 	}
-	buf1, err := ioutil.ReadAll(fd)
+	buf1, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -252,7 +251,7 @@ func TestFakeFSCaseInsensitive(t *testing.T) {
 func createTestDir(t *testing.T) (string, bool) {
 func createTestDir(t *testing.T) (string, bool) {
 	t.Helper()
 	t.Helper()
 
 
-	testDir, err := ioutil.TempDir("", "")
+	testDir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatalf("could not create temporary dir for testing: %s", err)
 		t.Fatalf("could not create temporary dir for testing: %s", err)
 	}
 	}
@@ -328,7 +327,7 @@ func testFakeFSCaseInsensitive(t *testing.T, fs Filesystem) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	bs2, err := ioutil.ReadAll(fd2)
+	bs2, err := io.ReadAll(fd2)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 2 - 3
lib/fs/filesystem_copy_range_test.go

@@ -9,7 +9,6 @@ package fs
 import (
 import (
 	"bytes"
 	"bytes"
 	"io"
 	"io"
-	"io/ioutil"
 	"math/rand"
 	"math/rand"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -257,7 +256,7 @@ func TestCopyRange(tttt *testing.T) {
 		paths = []string{""}
 		paths = []string{""}
 	}
 	}
 	for _, path := range paths {
 	for _, path := range paths {
-		testPath, err := ioutil.TempDir(path, "")
+		testPath, err := os.MkdirTemp(path, "")
 		if err != nil {
 		if err != nil {
 			tttt.Fatal(err)
 			tttt.Fatal(err)
 		}
 		}
@@ -273,7 +272,7 @@ func TestCopyRange(tttt *testing.T) {
 						tt.Run(testCase.name, func(t *testing.T) {
 						tt.Run(testCase.name, func(t *testing.T) {
 							srcBuf := make([]byte, testCase.srcSize)
 							srcBuf := make([]byte, testCase.srcSize)
 							dstBuf := make([]byte, testCase.dstSize)
 							dstBuf := make([]byte, testCase.dstSize)
-							td, err := ioutil.TempDir(testPath, "")
+							td, err := os.MkdirTemp(testPath, "")
 							if err != nil {
 							if err != nil {
 								t.Fatal(err)
 								t.Fatal(err)
 							}
 							}

+ 8 - 9
lib/fs/mtimefs_test.go

@@ -8,7 +8,6 @@ package fs
 
 
 import (
 import (
 	"errors"
 	"errors"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -20,9 +19,9 @@ func TestMtimeFS(t *testing.T) {
 	os.RemoveAll("testdata")
 	os.RemoveAll("testdata")
 	defer os.RemoveAll("testdata")
 	defer os.RemoveAll("testdata")
 	os.Mkdir("testdata", 0755)
 	os.Mkdir("testdata", 0755)
-	ioutil.WriteFile("testdata/exists0", []byte("hello"), 0644)
-	ioutil.WriteFile("testdata/exists1", []byte("hello"), 0644)
-	ioutil.WriteFile("testdata/exists2", []byte("hello"), 0644)
+	os.WriteFile("testdata/exists0", []byte("hello"), 0644)
+	os.WriteFile("testdata/exists1", []byte("hello"), 0644)
+	os.WriteFile("testdata/exists2", []byte("hello"), 0644)
 
 
 	// a random time with nanosecond precision
 	// a random time with nanosecond precision
 	testTime := time.Unix(1234567890, 123456789)
 	testTime := time.Unix(1234567890, 123456789)
@@ -83,7 +82,7 @@ func TestMtimeFS(t *testing.T) {
 }
 }
 
 
 func TestMtimeFSWalk(t *testing.T) {
 func TestMtimeFSWalk(t *testing.T) {
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -93,7 +92,7 @@ func TestMtimeFSWalk(t *testing.T) {
 	mtimefs := newMtimeFS(underlying, make(mapStore))
 	mtimefs := newMtimeFS(underlying, make(mapStore))
 	mtimefs.chtimes = failChtimes
 	mtimefs.chtimes = failChtimes
 
 
-	if err := ioutil.WriteFile(filepath.Join(dir, "file"), []byte("hello"), 0644); err != nil {
+	if err := os.WriteFile(filepath.Join(dir, "file"), []byte("hello"), 0644); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
@@ -137,7 +136,7 @@ func TestMtimeFSWalk(t *testing.T) {
 }
 }
 
 
 func TestMtimeFSOpen(t *testing.T) {
 func TestMtimeFSOpen(t *testing.T) {
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -147,7 +146,7 @@ func TestMtimeFSOpen(t *testing.T) {
 	mtimefs := newMtimeFS(underlying, make(mapStore))
 	mtimefs := newMtimeFS(underlying, make(mapStore))
 	mtimefs.chtimes = failChtimes
 	mtimefs.chtimes = failChtimes
 
 
-	if err := ioutil.WriteFile(filepath.Join(dir, "file"), []byte("hello"), 0644); err != nil {
+	if err := os.WriteFile(filepath.Join(dir, "file"), []byte("hello"), 0644); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
@@ -200,7 +199,7 @@ func TestMtimeFSInsensitive(t *testing.T) {
 		os.RemoveAll("testdata")
 		os.RemoveAll("testdata")
 		defer os.RemoveAll("testdata")
 		defer os.RemoveAll("testdata")
 		os.Mkdir("testdata", 0755)
 		os.Mkdir("testdata", 0755)
-		ioutil.WriteFile("testdata/FiLe", []byte("hello"), 0644)
+		os.WriteFile("testdata/FiLe", []byte("hello"), 0644)
 
 
 		// a random time with nanosecond precision
 		// a random time with nanosecond precision
 		testTime := time.Unix(1234567890, 123456789)
 		testTime := time.Unix(1234567890, 123456789)

+ 6 - 7
lib/ignore/ignore_test.go

@@ -10,7 +10,6 @@ import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -232,7 +231,7 @@ func TestCaseSensitivity(t *testing.T) {
 }
 }
 
 
 func TestCaching(t *testing.T) {
 func TestCaching(t *testing.T) {
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -425,7 +424,7 @@ flamingo
 *.crow
 *.crow
 	`
 	`
 	// Caches per file, hence write the patterns to a file.
 	// Caches per file, hence write the patterns to a file.
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		b.Fatal(err)
 		b.Fatal(err)
 	}
 	}
@@ -466,7 +465,7 @@ flamingo
 }
 }
 
 
 func TestCacheReload(t *testing.T) {
 func TestCacheReload(t *testing.T) {
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -989,7 +988,7 @@ func TestIssue4689(t *testing.T) {
 }
 }
 
 
 func TestIssue4901(t *testing.T) {
 func TestIssue4901(t *testing.T) {
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -1001,7 +1000,7 @@ func TestIssue4901(t *testing.T) {
 	puppy
 	puppy
 	`
 	`
 
 
-	if err := ioutil.WriteFile(filepath.Join(dir, ".stignore"), []byte(stignore), 0777); err != nil {
+	if err := os.WriteFile(filepath.Join(dir, ".stignore"), []byte(stignore), 0777); err != nil {
 		t.Fatalf(err.Error())
 		t.Fatalf(err.Error())
 	}
 	}
 
 
@@ -1020,7 +1019,7 @@ func TestIssue4901(t *testing.T) {
 		}
 		}
 	}
 	}
 
 
-	if err := ioutil.WriteFile(filepath.Join(dir, "unicorn-lazor-death"), []byte(" "), 0777); err != nil {
+	if err := os.WriteFile(filepath.Join(dir, "unicorn-lazor-death"), []byte(" "), 0777); err != nil {
 		t.Fatalf(err.Error())
 		t.Fatalf(err.Error())
 	}
 	}
 
 

+ 1 - 2
lib/logger/logger.go

@@ -10,7 +10,6 @@ package logger
 import (
 import (
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"strings"
 	"strings"
@@ -75,7 +74,7 @@ func New() Logger {
 	if os.Getenv("LOGGER_DISCARD") != "" {
 	if os.Getenv("LOGGER_DISCARD") != "" {
 		// Hack to completely disable logging, for example when running
 		// Hack to completely disable logging, for example when running
 		// benchmarks.
 		// benchmarks.
-		return newLogger(ioutil.Discard)
+		return newLogger(io.Discard)
 	}
 	}
 	return newLogger(controlStripper{os.Stdout})
 	return newLogger(controlStripper{os.Stdout})
 }
 }

+ 3 - 3
lib/logger/logger_test.go

@@ -6,7 +6,7 @@ package logger
 import (
 import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"log"
 	"log"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
@@ -186,12 +186,12 @@ func TestControlStripper(t *testing.T) {
 }
 }
 
 
 func BenchmarkLog(b *testing.B) {
 func BenchmarkLog(b *testing.B) {
-	l := newLogger(controlStripper{ioutil.Discard})
+	l := newLogger(controlStripper{io.Discard})
 	benchmarkLogger(b, l)
 	benchmarkLogger(b, l)
 }
 }
 
 
 func BenchmarkLogNoStripper(b *testing.B) {
 func BenchmarkLogNoStripper(b *testing.B) {
-	l := newLogger(ioutil.Discard)
+	l := newLogger(io.Discard)
 	benchmarkLogger(b, l)
 	benchmarkLogger(b, l)
 }
 }
 
 

+ 2 - 3
lib/model/folder_sendrecv_test.go

@@ -13,7 +13,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -680,8 +679,8 @@ func TestIssue3164(t *testing.T) {
 	ignDir := filepath.Join("issue3164", "oktodelete")
 	ignDir := filepath.Join("issue3164", "oktodelete")
 	subDir := filepath.Join(ignDir, "foobar")
 	subDir := filepath.Join(ignDir, "foobar")
 	must(t, ffs.MkdirAll(subDir, 0777))
 	must(t, ffs.MkdirAll(subDir, 0777))
-	must(t, ioutil.WriteFile(filepath.Join(tmpDir, subDir, "file"), []byte("Hello"), 0644))
-	must(t, ioutil.WriteFile(filepath.Join(tmpDir, ignDir, "file"), []byte("Hello"), 0644))
+	must(t, os.WriteFile(filepath.Join(tmpDir, subDir, "file"), []byte("Hello"), 0644))
+	must(t, os.WriteFile(filepath.Join(tmpDir, ignDir, "file"), []byte("Hello"), 0644))
 	file := protocol.FileInfo{
 	file := protocol.FileInfo{
 		Name: "issue3164",
 		Name: "issue3164",
 	}
 	}

+ 4 - 5
lib/model/model_test.go

@@ -12,7 +12,6 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"math/rand"
 	"math/rand"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -2152,7 +2151,7 @@ func TestIssue2782(t *testing.T) {
 	if err := os.MkdirAll(testDir+"/syncdir", 0755); err != nil {
 	if err := os.MkdirAll(testDir+"/syncdir", 0755); err != nil {
 		t.Skip(err)
 		t.Skip(err)
 	}
 	}
-	if err := ioutil.WriteFile(testDir+"/syncdir/file", []byte("hello, world\n"), 0644); err != nil {
+	if err := os.WriteFile(testDir+"/syncdir/file", []byte("hello, world\n"), 0644); err != nil {
 		t.Skip(err)
 		t.Skip(err)
 	}
 	}
 	if err := os.Symlink("syncdir", testDir+"/synclink"); err != nil {
 	if err := os.Symlink("syncdir", testDir+"/synclink"); err != nil {
@@ -2763,7 +2762,7 @@ func TestVersionRestore(t *testing.T) {
 	// In each file, we write the filename as the content
 	// In each file, we write the filename as the content
 	// We verify that the content matches at the expected filenames
 	// We verify that the content matches at the expected filenames
 	// after the restore operation.
 	// after the restore operation.
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	must(t, err)
 	must(t, err)
 	defer os.RemoveAll(dir)
 	defer os.RemoveAll(dir)
 
 
@@ -2900,7 +2899,7 @@ func TestVersionRestore(t *testing.T) {
 		}
 		}
 		defer fd.Close()
 		defer fd.Close()
 
 
-		content, err := ioutil.ReadAll(fd)
+		content, err := io.ReadAll(fd)
 		if err != nil {
 		if err != nil {
 			t.Error(err)
 			t.Error(err)
 		}
 		}
@@ -2930,7 +2929,7 @@ func TestVersionRestore(t *testing.T) {
 				must(t, err)
 				must(t, err)
 				defer fd.Close()
 				defer fd.Close()
 
 
-				content, err := ioutil.ReadAll(fd)
+				content, err := io.ReadAll(fd)
 				if err != nil {
 				if err != nil {
 					t.Error(err)
 					t.Error(err)
 				}
 				}

+ 2 - 3
lib/model/requests_test.go

@@ -10,7 +10,6 @@ import (
 	"bytes"
 	"bytes"
 	"context"
 	"context"
 	"errors"
 	"errors"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -236,7 +235,7 @@ func TestRequestVersioningSymlinkAttack(t *testing.T) {
 
 
 	// Create a temporary directory that we will use as target to see if
 	// Create a temporary directory that we will use as target to see if
 	// we can escape to it
 	// we can escape to it
-	tmpdir, err := ioutil.TempDir("", "syncthing-test")
+	tmpdir, err := os.MkdirTemp("", "syncthing-test")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -681,7 +680,7 @@ func TestRequestSymlinkWindows(t *testing.T) {
 }
 }
 
 
 func equalContents(path string, contents []byte) error {
 func equalContents(path string, contents []byte) error {
-	if bs, err := ioutil.ReadFile(path); err != nil {
+	if bs, err := os.ReadFile(path); err != nil {
 		return err
 		return err
 	} else if !bytes.Equal(bs, contents) {
 	} else if !bytes.Equal(bs, contents) {
 		return errors.New("incorrect data")
 		return errors.New("incorrect data")

+ 2 - 3
lib/model/testutils_test.go

@@ -8,7 +8,6 @@ package model
 
 
 import (
 import (
 	"context"
 	"context"
-	"io/ioutil"
 	"os"
 	"os"
 	"testing"
 	"testing"
 	"time"
 	"time"
@@ -76,7 +75,7 @@ func init() {
 }
 }
 
 
 func createTmpWrapper(cfg config.Configuration) (config.Wrapper, context.CancelFunc) {
 func createTmpWrapper(cfg config.Configuration) (config.Wrapper, context.CancelFunc) {
-	tmpFile, err := ioutil.TempFile("", "syncthing-testConfig-")
+	tmpFile, err := os.CreateTemp("", "syncthing-testConfig-")
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}
@@ -215,7 +214,7 @@ func cleanupModelAndRemoveDir(m *testModel, dir string) {
 }
 }
 
 
 func createTmpDir() string {
 func createTmpDir() string {
-	tmpDir, err := ioutil.TempDir("", "syncthing_testFolder-")
+	tmpDir, err := os.MkdirTemp("", "syncthing_testFolder-")
 	if err != nil {
 	if err != nil {
 		panic("Failed to create temporary testing dir")
 		panic("Failed to create temporary testing dir")
 	}
 	}

+ 1 - 2
lib/nat/structs_test.go

@@ -7,7 +7,6 @@
 package nat
 package nat
 
 
 import (
 import (
-	"io/ioutil"
 	"net"
 	"net"
 	"os"
 	"os"
 	"testing"
 	"testing"
@@ -60,7 +59,7 @@ func TestMappingValidGateway(t *testing.T) {
 }
 }
 
 
 func TestMappingClearAddresses(t *testing.T) {
 func TestMappingClearAddresses(t *testing.T) {
-	tmpFile, err := ioutil.TempFile("", "syncthing-testConfig-")
+	tmpFile, err := os.CreateTemp("", "syncthing-testConfig-")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 1
lib/osutil/atomic.go

@@ -43,7 +43,7 @@ func CreateAtomic(path string) (*AtomicWriter, error) {
 // permissions.
 // permissions.
 func CreateAtomicFilesystem(filesystem fs.Filesystem, path string) (*AtomicWriter, error) {
 func CreateAtomicFilesystem(filesystem fs.Filesystem, path string) (*AtomicWriter, error) {
 	// The security of this depends on the tempfile having secure
 	// The security of this depends on the tempfile having secure
-	// permissions, 0600, from the beginning. This is what ioutil.TempFile
+	// permissions, 0600, from the beginning. This is what os.CreateTemp
 	// does. We have a test that verifies that that is the case, should this
 	// does. We have a test that verifies that that is the case, should this
 	// ever change in the standard library in the future.
 	// ever change in the standard library in the future.
 	fd, err := TempFile(filesystem, filepath.Dir(path), TempPrefix)
 	fd, err := TempFile(filesystem, filepath.Dir(path), TempPrefix)

+ 5 - 6
lib/osutil/atomic_test.go

@@ -8,7 +8,6 @@ package osutil
 
 
 import (
 import (
 	"bytes"
 	"bytes"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"testing"
 	"testing"
@@ -35,7 +34,7 @@ func TestCreateAtomicCreate(t *testing.T) {
 		t.Fatal("written bytes", n, "!= 5")
 		t.Fatal("written bytes", n, "!= 5")
 	}
 	}
 
 
-	if _, err := ioutil.ReadFile("testdata/file"); err == nil {
+	if _, err := os.ReadFile("testdata/file"); err == nil {
 		t.Fatal("file should not exist")
 		t.Fatal("file should not exist")
 	}
 	}
 
 
@@ -43,7 +42,7 @@ func TestCreateAtomicCreate(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	bs, err := ioutil.ReadFile("testdata/file")
+	bs, err := os.ReadFile("testdata/file")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -62,7 +61,7 @@ func TestCreateAtomicReplaceReadOnly(t *testing.T) {
 func testCreateAtomicReplace(t *testing.T, oldPerms os.FileMode) {
 func testCreateAtomicReplace(t *testing.T, oldPerms os.FileMode) {
 	t.Helper()
 	t.Helper()
 
 
-	testdir, err := ioutil.TempDir("", "syncthing")
+	testdir, err := os.MkdirTemp("", "syncthing")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -75,7 +74,7 @@ func testCreateAtomicReplace(t *testing.T, oldPerms os.FileMode) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	if err := ioutil.WriteFile(testfile, []byte("some old data"), oldPerms); err != nil {
+	if err := os.WriteFile(testfile, []byte("some old data"), oldPerms); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
@@ -103,7 +102,7 @@ func testCreateAtomicReplace(t *testing.T, oldPerms os.FileMode) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	bs, err := ioutil.ReadFile(testfile)
+	bs, err := os.ReadFile(testfile)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 2
lib/osutil/atomic_unix_test.go

@@ -12,7 +12,6 @@
 package osutil
 package osutil
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"syscall"
 	"syscall"
 	"testing"
 	"testing"
@@ -24,7 +23,7 @@ func TestTempFilePermissions(t *testing.T) {
 	oldMask := syscall.Umask(0)
 	oldMask := syscall.Umask(0)
 	defer syscall.Umask(oldMask)
 	defer syscall.Umask(oldMask)
 
 
-	fd, err := ioutil.TempFile("", "test")
+	fd, err := os.CreateTemp("", "test")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 4 - 4
lib/osutil/osutil_test.go

@@ -7,7 +7,7 @@
 package osutil_test
 package osutil_test
 
 
 import (
 import (
-	"io/ioutil"
+	"io"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -83,7 +83,7 @@ func TestIsDeleted(t *testing.T) {
 func TestRenameOrCopy(t *testing.T) {
 func TestRenameOrCopy(t *testing.T) {
 	mustTempDir := func() string {
 	mustTempDir := func() string {
 		t.Helper()
 		t.Helper()
-		tmpDir, err := ioutil.TempDir("", "")
+		tmpDir, err := os.MkdirTemp("", "")
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
@@ -131,7 +131,7 @@ func TestRenameOrCopy(t *testing.T) {
 			if err != nil {
 			if err != nil {
 				t.Fatal(err)
 				t.Fatal(err)
 			}
 			}
-			buf, err := ioutil.ReadAll(fd)
+			buf, err := io.ReadAll(fd)
 			if err != nil {
 			if err != nil {
 				t.Fatal(err)
 				t.Fatal(err)
 			}
 			}
@@ -147,7 +147,7 @@ func TestRenameOrCopy(t *testing.T) {
 		if fd, err := test.dst.Open("new"); err != nil {
 		if fd, err := test.dst.Open("new"); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		} else {
 		} else {
-			if buf, err := ioutil.ReadAll(fd); err != nil {
+			if buf, err := io.ReadAll(fd); err != nil {
 				t.Fatal(err)
 				t.Fatal(err)
 			} else if string(buf) != content {
 			} else if string(buf) != content {
 				t.Fatalf("expected %s got %s", content, string(buf))
 				t.Fatalf("expected %s got %s", content, string(buf))

+ 2 - 3
lib/osutil/traversessymlink_test.go

@@ -7,7 +7,6 @@
 package osutil_test
 package osutil_test
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -18,7 +17,7 @@ import (
 )
 )
 
 
 func TestTraversesSymlink(t *testing.T) {
 func TestTraversesSymlink(t *testing.T) {
-	tmpDir, err := ioutil.TempDir(".", ".test-TraversesSymlink-")
+	tmpDir, err := os.MkdirTemp(".", ".test-TraversesSymlink-")
 	if err != nil {
 	if err != nil {
 		panic("Failed to create temporary testing dir")
 		panic("Failed to create temporary testing dir")
 	}
 	}
@@ -71,7 +70,7 @@ func TestTraversesSymlink(t *testing.T) {
 }
 }
 
 
 func TestIssue4875(t *testing.T) {
 func TestIssue4875(t *testing.T) {
-	tmpDir, err := ioutil.TempDir("", ".test-Issue4875-")
+	tmpDir, err := os.MkdirTemp("", ".test-Issue4875-")
 	if err != nil {
 	if err != nil {
 		panic("Failed to create temporary testing dir")
 		panic("Failed to create temporary testing dir")
 	}
 	}

+ 3 - 3
lib/protocol/protocol_test.go

@@ -10,7 +10,7 @@ import (
 	"encoding/json"
 	"encoding/json"
 	"errors"
 	"errors"
 	"io"
 	"io"
-	"io/ioutil"
+	"os"
 	"runtime"
 	"runtime"
 	"sync"
 	"sync"
 	"testing"
 	"testing"
@@ -432,8 +432,8 @@ func testMarshal(t *testing.T, prefix string, m1, m2 message) bool {
 	bs1, _ := json.MarshalIndent(m1, "", "  ")
 	bs1, _ := json.MarshalIndent(m1, "", "  ")
 	bs2, _ := json.MarshalIndent(m2, "", "  ")
 	bs2, _ := json.MarshalIndent(m2, "", "  ")
 	if !bytes.Equal(bs1, bs2) {
 	if !bytes.Equal(bs1, bs2) {
-		ioutil.WriteFile(prefix+"-1.txt", bs1, 0644)
-		ioutil.WriteFile(prefix+"-2.txt", bs2, 0644)
+		os.WriteFile(prefix+"-1.txt", bs1, 0644)
+		os.WriteFile(prefix+"-2.txt", bs2, 0644)
 		return false
 		return false
 	}
 	}
 
 

+ 1 - 2
lib/rc/rc.go

@@ -14,7 +14,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
@@ -393,7 +392,7 @@ func (p *Process) Model(folder string) (Model, error) {
 }
 }
 
 
 func (p *Process) readResponse(resp *http.Response) ([]byte, error) {
 func (p *Process) readResponse(resp *http.Response) ([]byte, error) {
-	bs, err := ioutil.ReadAll(resp.Body)
+	bs, err := io.ReadAll(resp.Body)
 	resp.Body.Close()
 	resp.Body.Close()
 	if err != nil {
 	if err != nil {
 		return bs, err
 		return bs, err

+ 3 - 4
lib/scanner/walk_test.go

@@ -13,7 +13,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -376,7 +375,7 @@ func TestWalkSymlinkWindows(t *testing.T) {
 
 
 func TestWalkRootSymlink(t *testing.T) {
 func TestWalkRootSymlink(t *testing.T) {
 	// Create a folder with a symlink in it
 	// Create a folder with a symlink in it
-	tmp, err := ioutil.TempDir("", "")
+	tmp, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -709,7 +708,7 @@ func TestStopWalk(t *testing.T) {
 }
 }
 
 
 func TestIssue4799(t *testing.T) {
 func TestIssue4799(t *testing.T) {
-	tmp, err := ioutil.TempDir("", "")
+	tmp, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -771,7 +770,7 @@ func TestRecurseInclude(t *testing.T) {
 }
 }
 
 
 func TestIssue4841(t *testing.T) {
 func TestIssue4841(t *testing.T) {
-	tmp, err := ioutil.TempDir("", "")
+	tmp, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 2
lib/syncthing/syncthing_test.go

@@ -7,7 +7,6 @@
 package syncthing
 package syncthing
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"testing"
 	"testing"
 	"time"
 	"time"
@@ -22,7 +21,7 @@ import (
 
 
 func tempCfgFilename(t *testing.T) string {
 func tempCfgFilename(t *testing.T) string {
 	t.Helper()
 	t.Helper()
-	f, err := ioutil.TempFile("", "syncthing-testConfig-")
+	f, err := os.CreateTemp("", "syncthing-testConfig-")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 2 - 3
lib/syncthing/utils.go

@@ -10,7 +10,6 @@ import (
 	"crypto/tls"
 	"crypto/tls"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 
 
 	"github.com/pkg/errors"
 	"github.com/pkg/errors"
@@ -133,12 +132,12 @@ func archiveAndSaveConfig(cfg config.Wrapper, originalVersion int) error {
 }
 }
 
 
 func copyFile(src, dst string) error {
 func copyFile(src, dst string) error {
-	bs, err := ioutil.ReadFile(src)
+	bs, err := os.ReadFile(src)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
 
 
-	if err := ioutil.WriteFile(dst, bs, 0600); err != nil {
+	if err := os.WriteFile(dst, bs, 0600); err != nil {
 		// Attempt to clean up
 		// Attempt to clean up
 		os.Remove(dst)
 		os.Remove(dst)
 		return err
 		return err

+ 3 - 4
lib/upgrade/upgrade_supported.go

@@ -19,7 +19,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
 	"path"
 	"path"
@@ -284,7 +283,7 @@ func readTarGz(archiveName, dir string, r io.Reader) (string, error) {
 }
 }
 
 
 func readZip(archiveName, dir string, r io.Reader) (string, error) {
 func readZip(archiveName, dir string, r io.Reader) (string, error) {
-	body, err := ioutil.ReadAll(r)
+	body, err := io.ReadAll(r)
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
 	}
 	}
@@ -357,7 +356,7 @@ func archiveFileVisitor(dir string, tempFile *string, signature *[]byte, archive
 
 
 	case "release.sig":
 	case "release.sig":
 		l.Debugf("found signature %s", archivePath)
 		l.Debugf("found signature %s", archivePath)
-		*signature, err = ioutil.ReadAll(io.LimitReader(filedata, maxSignatureSize))
+		*signature, err = io.ReadAll(io.LimitReader(filedata, maxSignatureSize))
 		if err != nil {
 		if err != nil {
 			return err
 			return err
 		}
 		}
@@ -407,7 +406,7 @@ func verifyUpgrade(archiveName, tempName string, sig []byte) error {
 func writeBinary(dir string, inFile io.Reader) (filename string, err error) {
 func writeBinary(dir string, inFile io.Reader) (filename string, err error) {
 	// Write the binary to a temporary file.
 	// Write the binary to a temporary file.
 
 
-	outFile, err := ioutil.TempFile(dir, "syncthing")
+	outFile, err := os.CreateTemp(dir, "syncthing")
 	if err != nil {
 	if err != nil {
 		return "", err
 		return "", err
 	}
 	}

+ 2 - 2
lib/upnp/upnp.go

@@ -38,7 +38,7 @@ import (
 	"context"
 	"context"
 	"encoding/xml"
 	"encoding/xml"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"net"
 	"net"
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
@@ -467,7 +467,7 @@ func soapRequest(ctx context.Context, url, service, function, message string) ([
 		return resp, err
 		return resp, err
 	}
 	}
 
 
-	resp, _ = ioutil.ReadAll(r.Body)
+	resp, _ = io.ReadAll(r.Body)
 	l.Debugf("SOAP Response: %s\n\n%s\n\n", r.Status, resp)
 	l.Debugf("SOAP Response: %s\n\n%s\n\n", r.Status, resp)
 
 
 	r.Body.Close()
 	r.Body.Close()

+ 1 - 2
lib/versioner/external_test.go

@@ -7,7 +7,6 @@
 package versioner
 package versioner
 
 
 import (
 import (
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"runtime"
 	"runtime"
@@ -85,7 +84,7 @@ func prepForRemoval(t *testing.T, file string) {
 	if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {
 	if err := os.MkdirAll(filepath.Dir(file), 0755); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	if err := ioutil.WriteFile(file, []byte("hello\n"), 0644); err != nil {
+	if err := os.WriteFile(file, []byte("hello\n"), 0644); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 }
 }

+ 2 - 2
lib/versioner/simple_test.go

@@ -7,8 +7,8 @@
 package versioner
 package versioner
 
 
 import (
 import (
-	"io/ioutil"
 	"math"
 	"math"
+	"os"
 	"path/filepath"
 	"path/filepath"
 	"testing"
 	"testing"
 	"time"
 	"time"
@@ -55,7 +55,7 @@ func TestSimpleVersioningVersionCount(t *testing.T) {
 		t.Skip("Test takes some time, skipping.")
 		t.Skip("Test takes some time, skipping.")
 	}
 	}
 
 
-	dir, err := ioutil.TempDir("", "")
+	dir, err := os.MkdirTemp("", "")
 	//defer os.RemoveAll(dir)
 	//defer os.RemoveAll(dir)
 	if err != nil {
 	if err != nil {
 		t.Error(err)
 		t.Error(err)

+ 3 - 3
lib/versioner/staggered_test.go

@@ -7,7 +7,7 @@
 package versioner
 package versioner
 
 
 import (
 import (
-	"io/ioutil"
+	"os"
 	"path/filepath"
 	"path/filepath"
 	"sort"
 	"sort"
 	"strconv"
 	"strconv"
@@ -133,11 +133,11 @@ func TestCreateVersionPath(t *testing.T) {
 	)
 	)
 
 
 	// Create a test dir and file
 	// Create a test dir and file
-	tmpDir, err := ioutil.TempDir("", "")
+	tmpDir, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	if err := ioutil.WriteFile(filepath.Join(tmpDir, archiveFile), []byte("sup"), 0644); err != nil {
+	if err := os.WriteFile(filepath.Join(tmpDir, archiveFile), []byte("sup"), 0644); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 

+ 5 - 4
lib/versioner/trashcan_test.go

@@ -7,7 +7,8 @@
 package versioner
 package versioner
 
 
 import (
 import (
-	"io/ioutil"
+	"io"
+	"os"
 	"testing"
 	"testing"
 	"time"
 	"time"
 
 
@@ -19,12 +20,12 @@ func TestTrashcanArchiveRestoreSwitcharoo(t *testing.T) {
 	// This tests that trashcan versioner restoration correctly archives existing file, because trashcan versioner
 	// This tests that trashcan versioner restoration correctly archives existing file, because trashcan versioner
 	// files are untagged, archiving existing file to replace with a restored version technically should collide in
 	// files are untagged, archiving existing file to replace with a restored version technically should collide in
 	// in names.
 	// in names.
-	tmpDir1, err := ioutil.TempDir("", "")
+	tmpDir1, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	tmpDir2, err := ioutil.TempDir("", "")
+	tmpDir2, err := os.MkdirTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -105,7 +106,7 @@ func readFile(t *testing.T, filesystem fs.Filesystem, name string) string {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	defer fd.Close()
 	defer fd.Close()
-	buf, err := ioutil.ReadAll(fd)
+	buf, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 2
lib/versioner/versioner_test.go

@@ -9,7 +9,6 @@ package versioner
 import (
 import (
 	"context"
 	"context"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"testing"
 	"testing"
@@ -56,7 +55,7 @@ func TestVersionerCleanOut(t *testing.T) {
 			oldTime := time.Now().Add(-8 * 24 * time.Hour)
 			oldTime := time.Now().Add(-8 * 24 * time.Hour)
 			for file, shouldRemove := range testcases {
 			for file, shouldRemove := range testcases {
 				os.MkdirAll(filepath.Dir(file), 0777)
 				os.MkdirAll(filepath.Dir(file), 0777)
-				if err := ioutil.WriteFile(file, []byte("data"), 0644); err != nil {
+				if err := os.WriteFile(file, []byte("data"), 0644); err != nil {
 					t.Fatal(err)
 					t.Fatal(err)
 				}
 				}
 				if shouldRemove {
 				if shouldRemove {

+ 1 - 2
lib/weakhash/weakhash_test.go

@@ -13,7 +13,6 @@ import (
 	"bytes"
 	"bytes"
 	"context"
 	"context"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"reflect"
 	"reflect"
 	"testing"
 	"testing"
@@ -22,7 +21,7 @@ import (
 var payload = []byte("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
 var payload = []byte("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
 
 
 func TestFinder(t *testing.T) {
 func TestFinder(t *testing.T) {
-	f, err := ioutil.TempFile("", "")
+	f, err := os.CreateTemp("", "")
 	if err != nil {
 	if err != nil {
 		t.Error(err)
 		t.Error(err)
 	}
 	}

+ 3 - 3
script/authors.go

@@ -15,7 +15,7 @@ package main
 import (
 import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"log"
 	"log"
 	"math"
 	"math"
 	"os"
 	"os"
@@ -108,7 +108,7 @@ func main() {
 	bs := readAll(htmlFile)
 	bs := readAll(htmlFile)
 	bs = authorsRe.ReplaceAll(bs, []byte("id=\"contributor-list\">\n"+replacement+"\n    </div>"))
 	bs = authorsRe.ReplaceAll(bs, []byte("id=\"contributor-list\">\n"+replacement+"\n    </div>"))
 
 
-	if err := ioutil.WriteFile(htmlFile, bs, 0644); err != nil {
+	if err := os.WriteFile(htmlFile, bs, 0644); err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}
 
 
@@ -173,7 +173,7 @@ func readAll(path string) []byte {
 	}
 	}
 	defer fd.Close()
 	defer fd.Close()
 
 
-	bs, err := ioutil.ReadAll(fd)
+	bs, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}

+ 1 - 2
script/commit-msg.go

@@ -12,7 +12,6 @@ package main
 import (
 import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"regexp"
 	"regexp"
@@ -31,7 +30,7 @@ func main() {
 		os.Exit(exitError)
 		os.Exit(exitError)
 	}
 	}
 
 
-	bs, err := ioutil.ReadFile(os.Args[1])
+	bs, err := os.ReadFile(os.Args[1])
 	if err != nil {
 	if err != nil {
 		fmt.Println("Reading input:", err)
 		fmt.Println("Reading input:", err)
 		os.Exit(exitError)
 		os.Exit(exitError)

+ 1 - 2
script/genassets.go

@@ -16,7 +16,6 @@ import (
 	"fmt"
 	"fmt"
 	"go/format"
 	"go/format"
 	"io"
 	"io"
-	"io/ioutil"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
 	"strconv"
 	"strconv"
@@ -74,7 +73,7 @@ func walkerFor(basePath string) filepath.WalkFunc {
 		}
 		}
 
 
 		if info.Mode().IsRegular() {
 		if info.Mode().IsRegular() {
-			data, err := ioutil.ReadFile(name)
+			data, err := os.ReadFile(name)
 			if err != nil {
 			if err != nil {
 				return err
 				return err
 			}
 			}

+ 1 - 2
script/prune_mocks.go

@@ -12,7 +12,6 @@ package main
 import (
 import (
 	"bufio"
 	"bufio"
 	"flag"
 	"flag"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"os/exec"
 	"os/exec"
@@ -51,7 +50,7 @@ func pruneInterfaceCheck(path string, size int64) error {
 	}
 	}
 	defer fd.Close()
 	defer fd.Close()
 
 
-	tmp, err := ioutil.TempFile(".", "")
+	tmp, err := os.CreateTemp(".", "")
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}

+ 2 - 2
script/transifexdl.go

@@ -12,7 +12,7 @@ package main
 import (
 import (
 	"encoding/json"
 	"encoding/json"
 	"fmt"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"log"
 	"log"
 	"net/http"
 	"net/http"
 	"os"
 	"os"
@@ -140,7 +140,7 @@ func loadValidLangs() []string {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}
 	defer fd.Close()
 	defer fd.Close()
-	bs, err := ioutil.ReadAll(fd)
+	bs, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		log.Fatal(err)
 		log.Fatal(err)
 	}
 	}

+ 15 - 16
test/conflict_test.go

@@ -11,7 +11,6 @@ package integration
 
 
 import (
 import (
 	"bytes"
 	"bytes"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -189,7 +188,7 @@ func TestConflictsDefault(t *testing.T) {
 	if len(files) != 1 {
 	if len(files) != 1 {
 		t.Errorf("Expected 1 conflicted files instead of %d", len(files))
 		t.Errorf("Expected 1 conflicted files instead of %d", len(files))
 	}
 	}
-	bs, err := ioutil.ReadFile("s1/testfile.txt")
+	bs, err := os.ReadFile("s1/testfile.txt")
 	if err != nil {
 	if err != nil {
 		t.Error("reading file:", err)
 		t.Error("reading file:", err)
 	}
 	}
@@ -216,26 +215,26 @@ func TestConflictsInitialMerge(t *testing.T) {
 
 
 	// File 1 is a conflict
 	// File 1 is a conflict
 
 
-	err = ioutil.WriteFile("s1/file1", []byte("hello\n"), 0644)
+	err = os.WriteFile("s1/file1", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
-	err = ioutil.WriteFile("s2/file1", []byte("goodbye\n"), 0644)
+	err = os.WriteFile("s2/file1", []byte("goodbye\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
 	// File 2 exists on s1 only
 	// File 2 exists on s1 only
 
 
-	err = ioutil.WriteFile("s1/file2", []byte("hello\n"), 0644)
+	err = os.WriteFile("s1/file2", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
 	// File 3 exists on s2 only
 	// File 3 exists on s2 only
 
 
-	err = ioutil.WriteFile("s2/file3", []byte("goodbye\n"), 0644)
+	err = os.WriteFile("s2/file3", []byte("goodbye\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -315,15 +314,15 @@ func TestConflictsIndexReset(t *testing.T) {
 
 
 	// Three files on s1
 	// Three files on s1
 
 
-	err = ioutil.WriteFile("s1/file1", []byte("hello\n"), 0644)
+	err = os.WriteFile("s1/file1", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = ioutil.WriteFile("s1/file2", []byte("hello\n"), 0644)
+	err = os.WriteFile("s1/file2", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = ioutil.WriteFile("s2/file3", []byte("hello\n"), 0644)
+	err = os.WriteFile("s2/file3", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -371,7 +370,7 @@ func TestConflictsIndexReset(t *testing.T) {
 	// locally after we rest the index, unless we have a fix for that.
 	// locally after we rest the index, unless we have a fix for that.
 
 
 	for i := 0; i < 5; i++ {
 	for i := 0; i < 5; i++ {
-		err = ioutil.WriteFile("s2/file2", []byte("hello1\n"), 0644)
+		err = os.WriteFile("s2/file2", []byte("hello1\n"), 0644)
 		if err != nil {
 		if err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
@@ -393,7 +392,7 @@ func TestConflictsIndexReset(t *testing.T) {
 
 
 	// s1/file1 (remote) changes while receiver is down
 	// s1/file1 (remote) changes while receiver is down
 
 
-	err = ioutil.WriteFile("s1/file1", []byte("goodbye\n"), 0644)
+	err = os.WriteFile("s1/file1", []byte("goodbye\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -406,7 +405,7 @@ func TestConflictsIndexReset(t *testing.T) {
 
 
 	// s2/file2 (local) changes while receiver is down
 	// s2/file2 (local) changes while receiver is down
 
 
-	err = ioutil.WriteFile("s2/file2", []byte("goodbye\n"), 0644)
+	err = os.WriteFile("s2/file2", []byte("goodbye\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -468,22 +467,22 @@ func TestConflictsSameContent(t *testing.T) {
 
 
 	// Two files on s1
 	// Two files on s1
 
 
-	err = ioutil.WriteFile("s1/file1", []byte("hello\n"), 0644)
+	err = os.WriteFile("s1/file1", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = ioutil.WriteFile("s1/file2", []byte("hello\n"), 0644)
+	err = os.WriteFile("s1/file2", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
 	// Two files on s2, content differs in file1 only, timestamps differ on both.
 	// Two files on s2, content differs in file1 only, timestamps differ on both.
 
 
-	err = ioutil.WriteFile("s2/file1", []byte("goodbye\n"), 0644)
+	err = os.WriteFile("s2/file1", []byte("goodbye\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = ioutil.WriteFile("s2/file2", []byte("hello\n"), 0644)
+	err = os.WriteFile("s2/file2", []byte("hello\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 2 - 2
test/delay_scan_test.go

@@ -10,8 +10,8 @@
 package integration
 package integration
 
 
 import (
 import (
-	"io/ioutil"
 	"log"
 	"log"
+	"os"
 	"sync"
 	"sync"
 	"testing"
 	"testing"
 	"time"
 	"time"
@@ -31,7 +31,7 @@ func TestRescanWithDelay(t *testing.T) {
 	}
 	}
 
 
 	log.Println("Generating .stignore...")
 	log.Println("Generating .stignore...")
-	err = ioutil.WriteFile("s1/.stignore", []byte("some ignore data\n"), 0644)
+	err = os.WriteFile("s1/.stignore", []byte("some ignore data\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 5 - 4
test/http_test.go

@@ -11,8 +11,9 @@ package integration
 
 
 import (
 import (
 	"bytes"
 	"bytes"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"net/http"
+	"os"
 	"strings"
 	"strings"
 	"testing"
 	"testing"
 
 
@@ -33,7 +34,7 @@ func TestHTTPGetIndex(t *testing.T) {
 	if res.StatusCode != 200 {
 	if res.StatusCode != 200 {
 		t.Errorf("Status %d != 200", res.StatusCode)
 		t.Errorf("Status %d != 200", res.StatusCode)
 	}
 	}
-	bs, err := ioutil.ReadAll(res.Body)
+	bs, err := io.ReadAll(res.Body)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -57,7 +58,7 @@ func TestHTTPGetIndex(t *testing.T) {
 	if res.StatusCode != 200 {
 	if res.StatusCode != 200 {
 		t.Errorf("Status %d != 200", res.StatusCode)
 		t.Errorf("Status %d != 200", res.StatusCode)
 	}
 	}
-	bs, err = ioutil.ReadAll(res.Body)
+	bs, err = io.ReadAll(res.Body)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -222,7 +223,7 @@ func setupAPIBench() *rc.Process {
 		panic(err)
 		panic(err)
 	}
 	}
 
 
-	err = ioutil.WriteFile("s1/knownfile", []byte("somedatahere"), 0644)
+	err = os.WriteFile("s1/knownfile", []byte("somedatahere"), 0644)
 	if err != nil {
 	if err != nil {
 		panic(err)
 		panic(err)
 	}
 	}

+ 2 - 3
test/ignore_test.go

@@ -10,7 +10,6 @@
 package integration
 package integration
 
 
 import (
 import (
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -67,7 +66,7 @@ func TestIgnores(t *testing.T) {
 
 
 	// Add some of them to an ignore file
 	// Add some of them to an ignore file
 
 
-	err = ioutil.WriteFile("s1/.stignore",
+	err = os.WriteFile("s1/.stignore",
 		[]byte("f1*\nf2\nd1*\nd2\ns1*\ns2\n(?i)*.txt"), // [fds][34] only non-ignored items
 		[]byte("f1*\nf2\nd1*\nd2\ns1*\ns2\n(?i)*.txt"), // [fds][34] only non-ignored items
 		0644)
 		0644)
 	if err != nil {
 	if err != nil {
@@ -92,7 +91,7 @@ func TestIgnores(t *testing.T) {
 	// Change the pattern to include some of the files and dirs previously ignored
 	// Change the pattern to include some of the files and dirs previously ignored
 
 
 	time.Sleep(1100 * time.Millisecond)
 	time.Sleep(1100 * time.Millisecond)
-	err = ioutil.WriteFile("s1/.stignore", []byte("f2\nd2\ns2\n"), 0644)
+	err = os.WriteFile("s1/.stignore", []byte("f2\nd2\ns2\n"), 0644)
 
 
 	// Rescan and verify that we see them
 	// Rescan and verify that we see them
 
 

+ 8 - 8
test/override_test.go

@@ -10,7 +10,7 @@
 package integration
 package integration
 
 
 import (
 import (
-	"io/ioutil"
+	"io"
 	"log"
 	"log"
 	"os"
 	"os"
 	"strings"
 	"strings"
@@ -127,7 +127,7 @@ func TestOverride(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err := ioutil.ReadAll(fd)
+	bs, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -141,7 +141,7 @@ func TestOverride(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err = ioutil.ReadAll(fd)
+	bs, err = io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -295,7 +295,7 @@ func TestOverrideIgnores(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err := ioutil.ReadAll(fd)
+	bs, err := io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -309,7 +309,7 @@ func TestOverrideIgnores(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err = ioutil.ReadAll(fd)
+	bs, err = io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -337,7 +337,7 @@ func TestOverrideIgnores(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err = ioutil.ReadAll(fd)
+	bs, err = io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -388,7 +388,7 @@ func TestOverrideIgnores(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err = ioutil.ReadAll(fd)
+	bs, err = io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -423,7 +423,7 @@ func TestOverrideIgnores(t *testing.T) {
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	bs, err = ioutil.ReadAll(fd)
+	bs, err = io.ReadAll(fd)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 2 - 2
test/parallell_scan_test.go

@@ -10,8 +10,8 @@
 package integration
 package integration
 
 
 import (
 import (
-	"io/ioutil"
 	"log"
 	"log"
+	"os"
 	"sync"
 	"sync"
 	"testing"
 	"testing"
 	"time"
 	"time"
@@ -31,7 +31,7 @@ func TestRescanInParallel(t *testing.T) {
 	}
 	}
 
 
 	log.Println("Generating .stignore...")
 	log.Println("Generating .stignore...")
-	err = ioutil.WriteFile("s1/.stignore", []byte("some ignore data\n"), 0644)
+	err = os.WriteFile("s1/.stignore", []byte("some ignore data\n"), 0644)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}

+ 1 - 2
test/reset_test.go

@@ -13,7 +13,6 @@ import (
 	"bytes"
 	"bytes"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
@@ -147,7 +146,7 @@ func createFiles(t *testing.T) int {
 	const n = 8
 	const n = 8
 	for i := 0; i < n; i++ {
 	for i := 0; i < n; i++ {
 		file := fmt.Sprintf("f%d", i)
 		file := fmt.Sprintf("f%d", i)
-		if err := ioutil.WriteFile(filepath.Join("s1", file), []byte("data"), 0644); err != nil {
+		if err := os.WriteFile(filepath.Join("s1", file), []byte("data"), 0644); err != nil {
 			t.Fatal(err)
 			t.Fatal(err)
 		}
 		}
 	}
 	}

+ 2 - 3
test/util.go

@@ -14,7 +14,6 @@ import (
 	"errors"
 	"errors"
 	"fmt"
 	"fmt"
 	"io"
 	"io"
-	"io/ioutil"
 	"log"
 	"log"
 	"math/rand"
 	"math/rand"
 	"os"
 	"os"
@@ -206,7 +205,7 @@ func alterFiles(dir string) error {
 							return err
 							return err
 						}
 						}
 						d1 := []byte("I used to be a dir: " + path)
 						d1 := []byte("I used to be a dir: " + path)
-						err := ioutil.WriteFile(path, d1, 0644)
+						err := os.WriteFile(path, d1, 0644)
 						if err != nil {
 						if err != nil {
 							return err
 							return err
 						}
 						}
@@ -551,7 +550,7 @@ func startInstance(t *testing.T, i int) *rc.Process {
 }
 }
 
 
 func symlinksSupported() bool {
 func symlinksSupported() bool {
-	tmp, err := ioutil.TempDir("", "symlink-test")
+	tmp, err := os.MkdirTemp("", "symlink-test")
 	if err != nil {
 	if err != nil {
 		return false
 		return false
 	}
 	}