Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: ["1.15"]
go-version:
- '1.20.x'
- '1.21.x'
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.19'
go-version: '1.20.x'

- name: Import GPG Key
id: import_gpg
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Exercism would be impossible without people like you being willing to spend time

## Dependencies

You'll need Go version 1.11 or higher. Follow the directions on http://golang.org/doc/install
You'll need Go version 1.20 or higher. Follow the directions on http://golang.org/doc/install

## Development

Expand Down
4 changes: 2 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package api

import (
"bytes"
"io/ioutil"
"os"

"golang.org/x/net/html/charset"
"golang.org/x/text/transform"
Expand All @@ -17,7 +17,7 @@ var (
)

func readFileAsUTF8String(filename string) (*string, error) {
b, err := ioutil.ReadFile(filename)
b, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions cli/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cli
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http"
)

Expand All @@ -28,7 +28,7 @@ func (a *Asset) download() (*bytes.Reader, error) {
}
defer res.Body.Close()

bs, err := ioutil.ReadAll(res.Body)
bs, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -161,8 +161,8 @@ func (c *CLI) fetchLatestRelease() error {
return nil
}

func extractBinary(source *bytes.Reader, os string) (binary io.ReadCloser, err error) {
if os == "windows" {
func extractBinary(source *bytes.Reader, platform string) (binary io.ReadCloser, err error) {
if platform == "windows" {
zr, err := zip.NewReader(source, int64(source.Len()))
if err != nil {
return nil, err
Expand Down Expand Up @@ -191,7 +191,7 @@ func extractBinary(source *bytes.Reader, os string) (binary io.ReadCloser, err e
if err != nil {
return nil, err
}
tmpfile, err := ioutil.TempFile("", "temp-exercism")
tmpfile, err := os.CreateTemp("", "temp-exercism")
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"io"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -63,7 +62,7 @@ type CommandTest struct {
// The method takes a *testing.T as an argument, that way the method can
// fail the test if the creation of the temporary directory fails.
func (test *CommandTest) Setup(t *testing.T) {
dir, err := ioutil.TempDir("", "command-test")
dir, err := os.MkdirTemp("", "command-test")
defer os.RemoveAll(dir)
assert.NoError(t, err)

Expand Down Expand Up @@ -104,8 +103,8 @@ func newCapturedOutput() capturedOutput {
return capturedOutput{
oldOut: Out,
oldErr: Err,
newOut: ioutil.Discard,
newErr: ioutil.Discard,
newOut: io.Discard,
newErr: io.Discard,
}
}

Expand Down
8 changes: 3 additions & 5 deletions cmd/configure_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//go:build !windows
// +build !windows

package cmd

import (
"bytes"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -344,7 +342,7 @@ func TestConfigureDefaultWorkspaceWithoutClobbering(t *testing.T) {
ts := httptest.NewServer(endpoint)
defer ts.Close()

tmpDir, err := ioutil.TempDir("", "no-clobber")
tmpDir, err := os.MkdirTemp("", "no-clobber")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)

Expand Down Expand Up @@ -379,7 +377,7 @@ func TestConfigureExplicitWorkspaceWithoutClobberingNonDirectory(t *testing.T) {
co.override()
defer co.reset()

tmpDir, err := ioutil.TempDir("", "no-clobber")
tmpDir, err := os.MkdirTemp("", "no-clobber")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)

Expand All @@ -396,7 +394,7 @@ func TestConfigureExplicitWorkspaceWithoutClobberingNonDirectory(t *testing.T) {
}

// Create a file at the workspace directory's location
err = ioutil.WriteFile(filepath.Join(tmpDir, "workspace"), []byte("This is not a directory"), os.FileMode(0755))
err = os.WriteFile(filepath.Join(tmpDir, "workspace"), []byte("This is not a directory"), os.FileMode(0755))
assert.NoError(t, err)

flags := pflag.NewFlagSet("fake", pflag.PanicOnError)
Expand Down
5 changes: 2 additions & 3 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
netURL "net/url"
"os"
Expand Down Expand Up @@ -202,8 +201,8 @@ func newDownload(flags *pflag.FlagSet, usrCfg *viper.Viper) (*download, error) {
return nil, decodedAPIError(res)
}

body, _ := ioutil.ReadAll(res.Body)
res.Body = ioutil.NopCloser(bytes.NewReader(body))
body, _ := io.ReadAll(res.Body)
res.Body = io.NopCloser(bytes.NewReader(body))

if err := json.Unmarshal(body, &d.payload); err != nil {
return nil, decodedAPIError(res)
Expand Down
13 changes: 6 additions & 7 deletions cmd/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -169,7 +168,7 @@ func TestDownload(t *testing.T) {
}

for _, tc := range testCases {
tmpDir, err := ioutil.TempDir("", "download-cmd")
tmpDir, err := os.MkdirTemp("", "download-cmd")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)

Expand Down Expand Up @@ -197,7 +196,7 @@ func TestDownload(t *testing.T) {
assertDownloadedCorrectFiles(t, targetDir)

dir := filepath.Join(targetDir, "bogus-track", "bogus-exercise")
b, err := ioutil.ReadFile(workspace.NewExerciseFromDir(dir).MetadataFilepath())
b, err := os.ReadFile(workspace.NewExerciseFromDir(dir).MetadataFilepath())
assert.NoError(t, err)
var metadata workspace.ExerciseMetadata
err = json.Unmarshal(b, &metadata)
Expand Down Expand Up @@ -229,7 +228,7 @@ func TestDownloadToExistingDirectory(t *testing.T) {
}

for _, tc := range testCases {
tmpDir, err := ioutil.TempDir("", "download-cmd")
tmpDir, err := os.MkdirTemp("", "download-cmd")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)

Expand Down Expand Up @@ -281,7 +280,7 @@ func TestDownloadToExistingDirectoryWithForce(t *testing.T) {
}

for _, tc := range testCases {
tmpDir, err := ioutil.TempDir("", "download-cmd")
tmpDir, err := os.MkdirTemp("", "download-cmd")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)

Expand Down Expand Up @@ -363,7 +362,7 @@ func assertDownloadedCorrectFiles(t *testing.T, targetDir string) {

for _, file := range expectedFiles {
t.Run(file.desc, func(t *testing.T) {
b, err := ioutil.ReadFile(file.path)
b, err := os.ReadFile(file.path)
assert.NoError(t, err)
assert.Equal(t, file.contents, string(b))
})
Expand All @@ -383,7 +382,7 @@ func TestDownloadError(t *testing.T) {
ts := httptest.NewServer(handler)
defer ts.Close()

tmpDir, err := ioutil.TempDir("", "submit-err-tmp-dir")
tmpDir, err := os.MkdirTemp("", "submit-err-tmp-dir")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)

Expand Down
8 changes: 3 additions & 5 deletions cmd/submit_symlink_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
//go:build !windows
// +build !windows

package cmd

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -25,12 +23,12 @@ func TestSubmitFilesInSymlinkedPath(t *testing.T) {
ts := fakeSubmitServer(t, submittedFiles)
defer ts.Close()

tmpDir, err := ioutil.TempDir("", "symlink-destination")
tmpDir, err := os.MkdirTemp("", "symlink-destination")
defer os.RemoveAll(tmpDir)
assert.NoError(t, err)
dstDir := filepath.Join(tmpDir, "workspace")

srcDir, err := ioutil.TempDir("", "symlink-source")
srcDir, err := os.MkdirTemp("", "symlink-source")
defer os.RemoveAll(srcDir)
assert.NoError(t, err)

Expand All @@ -53,7 +51,7 @@ func TestSubmitFilesInSymlinkedPath(t *testing.T) {
}

file := filepath.Join(dir, "file.txt")
err = ioutil.WriteFile(filepath.Join(dir, "file.txt"), []byte("This is a file."), os.FileMode(0755))
err = os.WriteFile(filepath.Join(dir, "file.txt"), []byte("This is a file."), os.FileMode(0755))
assert.NoError(t, err)

err = runSubmit(cfg, pflag.NewFlagSet("symlinks", pflag.PanicOnError), []string{file})
Expand Down
Loading