Releases: moznion/go-iprtb
Releases · moznion/go-iprtb
v0.5.0
New Features
Support JSON marshalling and unmarshalling for the Route struct value #14
Examples
Marshalling
func ExampleRoute_MarshalJSON() {
r := &Route{
Destination: &net.IPNet{
IP: net.IPv4(192, 0, 2, 0).To4(),
Mask: net.IPv4Mask(255, 255, 255, 0),
},
Gateway: net.IPv4(192, 0, 2, 1),
NetworkInterface: "ifb0",
Metric: 1,
}
marshalled, err := json.Marshal(r)
if err != nil {
panic(err)
}
fmt.Printf("%s\n", marshalled)
// Output:
// {"destination":"192.0.2.0/24","gateway":"192.0.2.1","networkInterface":"ifb0","metric":1}
}
Unmarshalling
func ExampleRoute_UnmarshalJSON() {
var r Route
err := json.Unmarshal([]byte(`{"destination":"192.0.2.0/24","gateway":"192.0.2.1","networkInterface":"ifb0","metric":1}`), &r)
if err != nil {
panic(err)
}
fmt.Printf("destination: %s\n", r.Destination.String())
fmt.Printf("gateway: %s\n", r.Gateway.String())
fmt.Printf("networkInterface: %s\n", r.NetworkInterface)
fmt.Printf("metric: %d\n", r.Metric)
// Output:
// destination: 192.0.2.0/24
// gateway: 192.0.2.1
// networkInterface: ifb0
// metric: 1
}
v0.4.0
v0.3.1
v0.3.0
v0.2.1
Performance Improvements
Prune a non-terminated branch on route removal #8
This change makes it prune a non-terminated branch on route removal. This change brings up better performance for routes searching like the following benchmark result:
$ go test -bench=. -benchmem
goos: linux
goarch: amd64
pkg: github.com/moznion/go-iprtb
cpu: 12th Gen Intel(R) Core(TM) i7-1280P
Benchmark_New-20 211061150 5.562 ns/op 0 B/op 0 allocs/op
Benchmark_Old-20 29355026 40.87 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/moznion/go-iprtb 2.999s
Maintenance
- Simplify the logic in addRoute() #9
v0.2.0
What's Changed
Breaking Changes
- Change the signatures that use
net.IPNet
#4
New Features
- Add an operation "ClearRoutes" to remove all routes from the routing table #5
- Remove an associated label mapping when it removes by
RemoveRoute()
instead ofRemoveRouteByLabel()
#6
Maintenance
- Organize the code structure #3