Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
39 changes: 17 additions & 22 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ main ]
branches: [ "main" ]
pull_request:
branches: [ main ]
branches: [ "main" ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go 1.x
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ^1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
go-version: '1.24'

- name: Build
run: go build -v .
run: go build -v ./...

- name: Test
run: go test -v .
run: go test -v ./...

lint:
name: "Run static analysis"
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: dominikh/staticcheck-action@v1.2.0
with:
version: "2022.1.1"
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: dominikh/staticcheck-action@v1
with:
version: "latest"
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module github.com/joneskoo/ipgrep

go 1.12
go 1.24

require inet.af/netaddr v0.0.0-20220811202034-502d2d690317
require inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a

require (
go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 // indirect
)
12 changes: 7 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE=
go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA=
go4.org/intern v0.0.0-20230525184215-6c62f75575cb h1:ae7kzL5Cfdmcecbh22ll7lYP3iuUdnfnhiPcSaDgH/8=
go4.org/intern v0.0.0-20230525184215-6c62f75575cb/go.mod h1:Ycrt6raEcnF5FTsLiLKkhBTO6DPX3RCUCUVnks3gFJU=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 h1:FyBZqvoA/jbNzuAWLQE2kG820zMAkcilx6BMjGbL/E4=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6 h1:lGdhQUN/cnWdSH3291CUuxSEqc+AsGTiDxPP3r2J0l4=
go4.org/unsafe/assume-no-moving-gc v0.0.0-20231121144256-b99613f794b6/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand All @@ -26,5 +28,5 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
inet.af/netaddr v0.0.0-20220811202034-502d2d690317 h1:U2fwK6P2EqmopP/hFLTOAjWTki0qgd4GMJn5X8wOleU=
inet.af/netaddr v0.0.0-20220811202034-502d2d690317/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k=
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a h1:1XCVEdxrvL6c0TGOhecLuB7U9zYNdxZEjvOqJreKZiM=
inet.af/netaddr v0.0.0-20230525184311-b8eac61e914a/go.mod h1:e83i32mAQOW1LAqEIweALsuK2Uw4mhQadA5r7b0Wobo=
15 changes: 8 additions & 7 deletions ipgrep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ package ipgrep_test

import (
"bytes"
"io/ioutil"
"io"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -210,13 +211,13 @@ func TestIpgrep(t *testing.T) {

func BenchmarkGrepMMask(b *testing.B) {
b.ReportAllocs()
input, err := ioutil.ReadFile("README.md")
input, err := os.ReadFile("README.md")
if err != nil {
b.Errorf("Failed to read README.md: %v", err)
}
for i := 0; i < b.N; i++ {
br := bytes.NewReader(input)
err := ipgrep.Grep(br, ioutil.Discard, "1.2.3.4m255.255.255.0")
err := ipgrep.Grep(br, io.Discard, "1.2.3.4m255.255.255.0")
if err != nil {
b.Errorf("Grep failed unexpectedly: %v", err)
}
Expand All @@ -225,13 +226,13 @@ func BenchmarkGrepMMask(b *testing.B) {

func BenchmarkGrepCIDR(b *testing.B) {
b.ReportAllocs()
input, err := ioutil.ReadFile("README.md")
input, err := os.ReadFile("README.md")
if err != nil {
b.Errorf("Failed to read README.md: %v", err)
}
for i := 0; i < b.N; i++ {
br := bytes.NewReader(input)
err := ipgrep.Grep(br, ioutil.Discard, "1.2.3.4/24")
err := ipgrep.Grep(br, io.Discard, "1.2.3.4/24")
if err != nil {
b.Errorf("Grep failed unexpectedly: %v", err)
}
Expand All @@ -240,13 +241,13 @@ func BenchmarkGrepCIDR(b *testing.B) {

func BenchmarkGrepIP(b *testing.B) {
b.ReportAllocs()
input, err := ioutil.ReadFile("README.md")
input, err := os.ReadFile("README.md")
if err != nil {
b.Errorf("Failed to read README.md: %v", err)
}
for i := 0; i < b.N; i++ {
br := bytes.NewReader(input)
err := ipgrep.Grep(br, ioutil.Discard, "1.2.3.4")
err := ipgrep.Grep(br, io.Discard, "1.2.3.4")
if err != nil {
b.Errorf("Grep failed unexpectedly: %v", err)
}
Expand Down