Skip to content

Commit

Permalink
Inline function
Browse files Browse the repository at this point in the history
It used to be more complex before we switched to net/netip. It no longer
adds anything.
  • Loading branch information
oschwald committed Aug 5, 2024
1 parent 49baf63 commit 5696338
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 4 additions & 11 deletions convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,12 @@ func convert(
return fmt.Errorf("reading CSV: %w", err)
}

p, err := makePrefix(record[0])
prefix, err := netip.ParsePrefix(record[0])
if err != nil {
return err
return fmt.Errorf("parsing network (%s): %w", record[0], err)
}
err = writer.Write(makeLine(p, record[1:]))

err = writer.Write(makeLine(prefix, record[1:]))
if err != nil {
return fmt.Errorf("writing CSV: %w", err)
}
Expand All @@ -217,11 +218,3 @@ func convert(

return nil
}

func makePrefix(network string) (netip.Prefix, error) {
prefix, err := netip.ParsePrefix(network)
if err != nil {
return prefix, fmt.Errorf("parsing network (%s): %w", network, err)
}
return prefix, nil
}
3 changes: 2 additions & 1 deletion convert/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"net/netip"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -127,7 +128,7 @@ func checkLine(
network string,
expected []string,
) {
p, err := makePrefix(network)
p, err := netip.ParsePrefix(network)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 5696338

Please sign in to comment.