Skip to content

Commit 86b56b5

Browse files
committed
Remove ioutil uses, remove unused code
1 parent 3592462 commit 86b56b5

10 files changed

Lines changed: 20 additions & 33 deletions

File tree

cmd/editor/editor.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package main
55

66
import (
7-
"io/ioutil"
87
"os"
98
"syscall/js"
109

@@ -45,7 +44,7 @@ func (j *jsEditor) onEdit(js.Value, []js.Value) interface{} {
4544
if err == nil {
4645
perm = info.Mode()
4746
}
48-
err = ioutil.WriteFile(j.filePath, []byte(contents), perm)
47+
err = os.WriteFile(j.filePath, []byte(contents), perm)
4948
if err != nil {
5049
log.Error("Failed to write file contents: ", err)
5150
}
@@ -64,7 +63,7 @@ func (j *jsEditor) CurrentFile() string {
6463
}
6564

6665
func (j *jsEditor) ReloadFile() error {
67-
contents, err := ioutil.ReadFile(j.filePath)
66+
contents, err := os.ReadFile(j.filePath)
6867
if err != nil {
6968
return err
7069
}

cmd/editor/ide/window.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package ide
66
import (
77
_ "embed"
88
"go/format"
9-
"io/ioutil"
9+
"os"
1010
"strings"
1111
"syscall/js"
1212

@@ -100,7 +100,7 @@ func New(elem *dom.Element, editorBuilder EditorBuilder, consoleBuilder ConsoleB
100100
}
101101

102102
go func() {
103-
src, err := ioutil.ReadFile(path)
103+
src, err := os.ReadFile(path)
104104
if err != nil {
105105
log.Errorf("Failed to read Go file %q: %v", path, err)
106106
return
@@ -110,7 +110,7 @@ func New(elem *dom.Element, editorBuilder EditorBuilder, consoleBuilder ConsoleB
110110
log.Errorf("Failed to format Go file %q: %v", path, err)
111111
return
112112
}
113-
err = ioutil.WriteFile(path, out, 0)
113+
err = os.WriteFile(path, out, 0)
114114
if err != nil {
115115
log.Errorf("Failed to write Go file %q: %v", path, err)
116116
return

cmd/editor/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package main
55

66
import (
77
"flag"
8-
"io/ioutil"
98
"os"
109
"syscall/js"
1110

@@ -86,7 +85,7 @@ func main() {
8685
fmt.Println("Hello from Wasm!", datasize.Gigabytes(4))
8786
}
8887
`
89-
err := ioutil.WriteFile("main.go", []byte(mainGoContents), 0600)
88+
err := os.WriteFile("main.go", []byte(mainGoContents), 0600)
9089
if err != nil {
9190
log.Error("Failed to write to main.go: ", err)
9291
return

cmd/editor/plaineditor/editor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package plaineditor
55

66
import (
7-
"io/ioutil"
7+
"os"
88
"syscall/js"
99

1010
"github.com/hack-pad/hackpad/cmd/editor/dom"
@@ -51,7 +51,7 @@ func (e *textAreaEditor) CurrentFile() string {
5151
}
5252

5353
func (e *textAreaEditor) ReloadFile() error {
54-
contents, err := ioutil.ReadFile(e.filePath)
54+
contents, err := os.ReadFile(e.filePath)
5555
if err != nil {
5656
return err
5757
}
@@ -60,7 +60,7 @@ func (e *textAreaEditor) ReloadFile() error {
6060
}
6161

6262
func (e *textAreaEditor) edited(newContents func() string) {
63-
err := ioutil.WriteFile(e.filePath, []byte(newContents()), 0600)
63+
err := os.WriteFile(e.filePath, []byte(newContents()), 0600)
6464
if err != nil {
6565
log.Errorf("Failed to write %s: %s", e.filePath, err.Error())
6666
return

cmd/editor/plaineditor/typer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ func handleKeydown(event js.Value) {
6161
if code == KeyEnter {
6262
// TODO restore cmd+enter triggering run button
6363
// if metaKey {
64-
//preventDefault()
65-
//runPlayground()
66-
//return
67-
//}
64+
// preventDefault()
65+
// runPlayground()
66+
// return
67+
// }
6868

6969
lastNewLine := strings.LastIndexByte(slice(text, 0, selectionStart), '\n')
7070
if lastNewLine != -1 {

cmd/sh/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package main
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"log"
66
"os"
77

88
"github.com/hack-pad/hush"
99
)
1010

1111
func main() {
12-
log.SetOutput(ioutil.Discard)
12+
log.SetOutput(io.Discard)
1313
exitCode := hush.Run()
1414
os.Exit(exitCode)
1515
}

internal/fs/pipe.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ func newPipe(newFID func() FID) (r, w *fileDescriptor) {
3838
}
3939

4040
type pipeChan struct {
41-
unimplementedFile
42-
4341
buf chan byte
4442
done chan struct{}
4543
reader, writer FID

internal/interop/event.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,8 @@ func NewEventTarget() EventTarget {
2222
}
2323

2424
type Event struct {
25-
Target js.Value
26-
Type string
27-
stopPropagation bool
28-
}
29-
30-
func (e Event) StopPropagation() {
31-
e.stopPropagation = true
32-
}
33-
34-
func (e Event) Stopped() bool {
35-
return e.stopPropagation
25+
Target js.Value
26+
Type string
3627
}
3728

3829
type eventTarget struct {

internal/interop/profile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func ProfileJS(this js.Value, args []js.Value) interface{} {
2020
MemoryProfileJS(this, args)
2121
// Re-enable once these profiles actually work in the browser. Currently produces 0 samples.
2222
// TraceProfileJS(this, args)
23-
//StartCPUProfileJS(this, args)
23+
// StartCPUProfileJS(this, args)
2424
}()
2525
return nil
2626
}

internal/log/js_log.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ func logJSValues(kind consoleType, args ...interface{}) int {
6464
}
6565
jsArgs = append(jsArgs, jsArg)
6666
}
67-
console.Call(kind.String(), jsArgs...)
67+
_, _ = console.Call(kind.String(), jsArgs...)
6868
return 0
6969
}
7070

7171
func writeLog(c consoleType, s string) {
72-
console.Call(c.String(), s)
72+
_, _ = console.Call(c.String(), s)
7373
}

0 commit comments

Comments
 (0)