Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: remove usage of ioutil#642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
coadler merged 1 commit intomainfromcolin/ioutil
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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: 2 additions & 2 deletions.golangci.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ linters-settings:
-codegenComment
# - commentedOutCode
-commentedOutImport
#- commentFormatting
-commentFormatting
-defaultCaseOrder
-deferUnlambda
# - deprecatedComment
Expand All@@ -54,7 +54,7 @@ linters-settings:
# - importShadow
-indexAlloc
-initClause
#- ioutilDeprecated
-ioutilDeprecated
-mapKey
-methodExprCall
# - nestingReduce
Expand Down
4 changes: 2 additions & 2 deletionscli/config/file.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
package config

import (
"io/ioutil"
"io"
"os"
"path/filepath"
)
Expand DownExpand Up@@ -67,5 +67,5 @@ func read(path string) ([]byte, error) {
returnnil,err
}
deferfi.Close()
returnioutil.ReadAll(fi)
returnio.ReadAll(fi)
}
9 changes: 5 additions & 4 deletionscli/login.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,8 +3,9 @@ package cli
import (
"errors"
"fmt"
"io/ioutil"
"io"
"net/url"
"os"
"os/exec"
"os/user"
"runtime"
Expand All@@ -30,8 +31,8 @@ func init() {
// when in SSH or another type of headless session
// NOTE: This needs to be in `init` to prevent data races
// (multiple threads trying to set the global browser.Std* variables)
browser.Stderr =ioutil.Discard
browser.Stdout =ioutil.Discard
browser.Stderr =io.Discard
browser.Stdout =io.Discard
}

func login() *cobra.Command {
Expand DownExpand Up@@ -205,7 +206,7 @@ func isWSL() (bool, error) {
if runtime.GOOS == goosDarwin || runtime.GOOS == goosWindows {
return false, nil
}
data, err :=ioutil.ReadFile("/proc/version")
data, err :=os.ReadFile("/proc/version")
if err != nil {
return false, xerrors.Errorf("read /proc/version: %w", err)
}
Expand Down
7 changes: 4 additions & 3 deletionscli/start.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@ import (
"database/sql"
"encoding/pem"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand DownExpand Up@@ -383,10 +382,12 @@ func newProvisionerDaemon(ctx context.Context, client *codersdk.Client, logger s
panic(err)
}
}()
tempDir, err := ioutil.TempDir("", "provisionerd")

tempDir, err := os.MkdirTemp("", "provisionerd")
if err != nil {
return nil, err
}

return provisionerd.New(client.ListenProvisionerDaemon, &provisionerd.Options{
Logger: logger,
PollInterval: 50 * time.Millisecond,
Expand DownExpand Up@@ -473,7 +474,7 @@ func configureTLS(listener net.Listener, tlsMinVersion, tlsClientAuth, tlsCertFi

if tlsClientCAFile != "" {
caPool := x509.NewCertPool()
data, err :=ioutil.ReadFile(tlsClientCAFile)
data, err :=os.ReadFile(tlsClientCAFile)
if err != nil {
return nil, xerrors.Errorf("read %q: %w", tlsClientCAFile, err)
}
Expand Down
7 changes: 4 additions & 3 deletionscmd/templater/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"net/http/httptest"
"net/url"
Expand DownExpand Up@@ -263,10 +262,12 @@ func newProvisionerDaemon(ctx context.Context, client *codersdk.Client, logger s
panic(err)
}
}()
tempDir, err := ioutil.TempDir("", "provisionerd")

tempDir, err := os.MkdirTemp("", "provisionerd")
if err != nil {
return nil, err
return nil,xerrors.Errorf("mkdir temp: %w",err)
}

return provisionerd.New(client.ListenProvisionerDaemon, &provisionerd.Options{
Logger: logger,
PollInterval: 50 * time.Millisecond,
Expand Down
11 changes: 5 additions & 6 deletionscoderd/coderdtest/coderdtest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,6 @@ import (
"encoding/json"
"encoding/pem"
"io"
"io/ioutil"
"math/big"
"net"
"net/http"
Expand DownExpand Up@@ -323,7 +322,7 @@ func NewGoogleInstanceIdentity(t *testing.T, instanceID string, expired bool) (*
require.NoError(t,err)
return&http.Response{
StatusCode:http.StatusOK,
Body:ioutil.NopCloser(bytes.NewReader(data)),
Body:io.NopCloser(bytes.NewReader(data)),
Header:make(http.Header),
},nil
}),
Expand All@@ -334,7 +333,7 @@ func NewGoogleInstanceIdentity(t *testing.T, instanceID string, expired bool) (*
Transport:roundTripper(func(r*http.Request) (*http.Response,error) {
return&http.Response{
StatusCode:http.StatusOK,
Body:ioutil.NopCloser(bytes.NewReader([]byte(signedKey))),
Body:io.NopCloser(bytes.NewReader([]byte(signedKey))),
Header:make(http.Header),
},nil
}),
Expand DownExpand Up@@ -379,19 +378,19 @@ func NewAWSInstanceIdentity(t *testing.T, instanceID string) (awsidentity.Certif
case"/latest/api/token":
return&http.Response{
StatusCode:http.StatusOK,
Body:ioutil.NopCloser(bytes.NewReader([]byte("faketoken"))),
Body:io.NopCloser(bytes.NewReader([]byte("faketoken"))),
Header:make(http.Header),
},nil
case"/latest/dynamic/instance-identity/signature":
return&http.Response{
StatusCode:http.StatusOK,
Body:ioutil.NopCloser(bytes.NewReader(signature)),
Body:io.NopCloser(bytes.NewReader(signature)),
Header:make(http.Header),
},nil
case"/latest/dynamic/instance-identity/document":
return&http.Response{
StatusCode:http.StatusOK,
Body:ioutil.NopCloser(bytes.NewReader(document)),
Body:io.NopCloser(bytes.NewReader(document)),
Header:make(http.Header),
},nil
default:
Expand Down
3 changes: 1 addition & 2 deletionscoderd/database/dump/main.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ import (
"bytes"
"database/sql"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand DownExpand Up@@ -81,7 +80,7 @@ func main() {
if !ok {
panic("couldn't get caller path")
}
err =ioutil.WriteFile(filepath.Join(mainPath, "..", "..", "dump.sql"), []byte(dump), 0600)
err =os.WriteFile(filepath.Join(mainPath, "..", "..", "dump.sql"), []byte(dump), 0600)
if err != nil {
panic(err)
}
Expand Down
5 changes: 3 additions & 2 deletionscoderd/database/postgres/postgres.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@ package postgres
import (
"database/sql"
"fmt"
"io/ioutil"
"net"
"os"
"sync"
Expand DownExpand Up@@ -48,10 +47,12 @@ func Open() (string, func(), error) {
if err != nil {
return "", nil, xerrors.Errorf("create pool: %w", err)
}
tempDir, err := ioutil.TempDir(os.TempDir(), "postgres")

tempDir, err := os.MkdirTemp(os.TempDir(), "postgres")
if err != nil {
return "", nil, xerrors.Errorf("create tempdir: %w", err)
}

openPortMutex.Lock()
// Pick an explicit port on the host to connect to 5432.
// This is necessary so we can configure the port to only use ipv4.
Expand Down
5 changes: 2 additions & 3 deletionsprovisionersdk/archive_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
package provisionersdk_test

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All@@ -14,7 +13,7 @@ import (
func TestTar(t *testing.T) {
t.Parallel()
dir := t.TempDir()
file, err :=ioutil.TempFile(dir, "")
file, err :=os.CreateTemp(dir, "")
require.NoError(t, err)
_ = file.Close()
_, err = provisionersdk.Tar(dir)
Expand All@@ -24,7 +23,7 @@ func TestTar(t *testing.T) {
func TestUntar(t *testing.T) {
t.Parallel()
dir := t.TempDir()
file, err :=ioutil.TempFile(dir, "")
file, err :=os.CreateTemp(dir, "")
require.NoError(t, err)
_ = file.Close()
archive, err := provisionersdk.Tar(dir)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp