check / check (push) Canceled after 0s
Takes .golangci.yml, .dockerignore, .gitignore, .editorconfig, the workflow and REPO_POLICIES.md from sneak/prompts 0653579, with this repository's own entries after the shared content. Lint (golangci-lint v2.14.0) and test are Dockerfile phases that script/lint and script/test build alone with a new CACHEBUST value, keeping Go's and golangci-lint's caches; the image build depends on both. make fmt and make fmt-check also format the markdown with prettier, pinned in yarn.lock. The agent guidance moves to AGENTS.md. The Go code is fixed for what the new configuration finds, and the AS and prefix detail reads now return the rows' error after their loops. Model: opus-5-5
35 lines
663 B
Go
35 lines
663 B
Go
package database
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"strings"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func generateUUID() uuid.UUID {
|
|
return uuid.New()
|
|
}
|
|
|
|
// detectIPVersion determines if a prefix is IPv4 (returns 4) or IPv6 (returns 6)
|
|
func detectIPVersion(prefix string) int {
|
|
if strings.Contains(prefix, ":") {
|
|
return ipVersionV6
|
|
}
|
|
|
|
return ipVersionV4
|
|
}
|
|
|
|
// prefixMaskLength returns the mask length of a prefix such as 192.0.2.0/24.
|
|
func prefixMaskLength(prefix string) (int, error) {
|
|
_, network, err := net.ParseCIDR(prefix)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("invalid prefix %s: %w", prefix, err)
|
|
}
|
|
|
|
maskLength, _ := network.Mask.Size()
|
|
|
|
return maskLength, nil
|
|
}
|