Skip to content

Commit 3afec90

Browse files
authored
Merge pull request #99 from codecrafters-io/fix-double-uncomment
fix double uncomment
2 parents 2c0222f + 669b20f commit 3afec90

File tree

5 files changed

+12
-32
lines changed

5 files changed

+12
-32
lines changed

compiled_starters/go/cmd/mygrep/main.go

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

33
import (
4-
// Uncomment this to pass the first stage
5-
// "bytes"
4+
"bytes"
65
"fmt"
76
"io"
87
"os"
98
"unicode/utf8"
109
)
1110

11+
// Ensures gofmt doesn't remove the "bytes" import above (feel free to remove this!)
12+
var _ = bytes.ContainsAny
13+
1214
// Usage: echo <input_text> | your_program.sh -E <pattern>
1315
func main() {
1416
if len(os.Args) < 3 || os.Args[1] != "-E" {

solutions/go/01-cq2/code/cmd/mygrep/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"unicode/utf8"
99
)
1010

11+
// Ensures gofmt doesn't remove the "bytes" import above (feel free to remove this!)
12+
var _ = bytes.ContainsAny
13+
1114
// Usage: echo <input_text> | your_program.sh -E <pattern>
1215
func main() {
1316
if len(os.Args) < 3 || os.Args[1] != "-E" {

solutions/go/01-cq2/diff/cmd/mygrep/main.go.diff

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,4 @@
1-
@@ -1,54 +1,49 @@
2-
package main
3-
4-
import (
5-
- // Uncomment this to pass the first stage
6-
- // "bytes"
7-
+ "bytes"
8-
"fmt"
9-
"io"
10-
"os"
11-
"unicode/utf8"
12-
)
13-
14-
// Usage: echo <input_text> | your_program.sh -E <pattern>
15-
func main() {
16-
if len(os.Args) < 3 || os.Args[1] != "-E" {
17-
fmt.Fprintf(os.Stderr, "usage: mygrep -E <pattern>\n")
18-
os.Exit(2) // 1 means no lines were selected, >1 means error
19-
}
20-
21-
pattern := os.Args[2]
22-
23-
line, err := io.ReadAll(os.Stdin) // assume we're only dealing with a single line
1+
@@ -24,33 +24,29 @@
242
if err != nil {
253
fmt.Fprintf(os.Stderr, "error: read input text: %v\n", err)
264
os.Exit(2)

solutions/go/01-cq2/explanation.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ The entry point for your grep implementation is in `cmd/mygrep/main.go`.
22

33
Study and uncomment the relevant code:
44

5-
```go
6-
// Uncomment this to pass the first stage
7-
"bytes"
8-
```
9-
105
```go
116
// Uncomment this to pass the first stage
127
ok = bytes.ContainsAny(line, pattern)

starter_templates/go/code/cmd/mygrep/main.go

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

33
import (
4-
// Uncomment this to pass the first stage
5-
// "bytes"
4+
"bytes"
65
"fmt"
76
"io"
87
"os"
98
"unicode/utf8"
109
)
1110

11+
// Ensures gofmt doesn't remove the "bytes" import above (feel free to remove this!)
12+
var _ = bytes.ContainsAny
13+
1214
// Usage: echo <input_text> | your_program.sh -E <pattern>
1315
func main() {
1416
if len(os.Args) < 3 || os.Args[1] != "-E" {

0 commit comments

Comments
 (0)