check / check (push) Waiting to run
Takes .golangci.yml, .dockerignore, .gitignore, .editorconfig, the workflow and REPO_POLICIES.md from sneak/prompts dd4027b, keeping this repository's own entries after the shared content. Lint (golangci-lint v2.14.0) and test become Dockerfile phases that script/lint and script/test build alone and uncached; the image build depends on both, and script/cibuild bootstraps, runs script/check, then builds the image. The agent guidance file moves to AGENTS.md. The Go code is fixed for what the new configuration finds; reads that iterate rows now also report an iteration error. 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
|
|
}
|