Skip to content

Commit

Permalink
Merge pull request #16 from codecrafters-io/fix-double-uncomment
Browse files Browse the repository at this point in the history
fix double uncomment
  • Loading branch information
rohitpaulk authored Aug 27, 2024
2 parents 68656c5 + 336ae92 commit 725e9d7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 32 deletions.
6 changes: 4 additions & 2 deletions compiled_starters/go/cmd/mygrep/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package main

import (
// Uncomment this to pass the first stage
// "bytes"
"bytes"
"fmt"
"io"
"os"
"unicode/utf8"
)

// Ensures gofmt doesn't remove the "bytes" import above (feel free to remove this!)
var _ = bytes.ContainsAny

// Usage: echo <input_text> | your_grep.sh -E <pattern>
func main() {
if len(os.Args) < 3 || os.Args[1] != "-E" {
Expand Down
3 changes: 3 additions & 0 deletions solutions/go/01-oq4/code/cmd/mygrep/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"unicode/utf8"
)

// Ensures gofmt doesn't remove the "bytes" import above (feel free to remove this!)
var _ = bytes.ContainsAny

// Usage: echo <input_text> | your_grep.sh -E <pattern>
func main() {
if len(os.Args) < 3 || os.Args[1] != "-E" {
Expand Down
24 changes: 1 addition & 23 deletions solutions/go/01-oq4/diff/cmd/mygrep/main.go.diff
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
@@ -1,54 +1,49 @@
package main

import (
- // Uncomment this to pass the first stage
- // "bytes"
+ "bytes"
"fmt"
"io"
"os"
"unicode/utf8"
)

// Usage: echo <input_text> | your_grep.sh -E <pattern>
func main() {
if len(os.Args) < 3 || os.Args[1] != "-E" {
fmt.Fprintf(os.Stderr, "usage: mygrep -E <pattern>\n")
os.Exit(2) // 1 means no lines were selected, >1 means error
}

pattern := os.Args[2]

line, err := io.ReadAll(os.Stdin) // assume we're only dealing with a single line
@@ -24,33 +24,29 @@
if err != nil {
fmt.Fprintf(os.Stderr, "error: read input text: %v\n", err)
os.Exit(2)
Expand Down
5 changes: 0 additions & 5 deletions solutions/go/01-oq4/explanation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ The entry point for your writers-stg implementation is in `cmd/mygrep/main.go`.

Study and uncomment the relevant code:

```go
// Uncomment this to pass the first stage
"bytes"
```

```go
// Uncomment this to pass the first stage
ok = bytes.ContainsAny(line, pattern)
Expand Down
6 changes: 4 additions & 2 deletions starter_templates/go/code/cmd/mygrep/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package main

import (
// Uncomment this to pass the first stage
// "bytes"
"bytes"
"fmt"
"io"
"os"
"unicode/utf8"
)

// Ensures gofmt doesn't remove the "bytes" import above (feel free to remove this!)
var _ = bytes.ContainsAny

// Usage: echo <input_text> | your_grep.sh -E <pattern>
func main() {
if len(os.Args) < 3 || os.Args[1] != "-E" {
Expand Down

0 comments on commit 725e9d7

Please sign in to comment.