Skip to content

Commit

Permalink
golang changes over time
Browse files Browse the repository at this point in the history
  • Loading branch information
mabels committed Jan 2, 2021
1 parent 704f4c4 commit 2566658
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 19 deletions.
8 changes: 5 additions & 3 deletions go/ipaddress/assert_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ipaddress

import "math/big"
import "testing"
import (
"math/big"
"testing"
)

// type gochaFunc func() string

Expand Down Expand Up @@ -43,7 +45,7 @@ func (self *MyTesting) assert(b bool) {

func (self *MyTesting) assert_bool(a bool, b bool) {
if a != b {
self.t.Errorf("[%s] != [%s]", a, b)
self.t.Errorf("[%t] != [%t]", a, b)
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/ipaddress/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ func (self *IPAddress) Is_private() bool {

func (self *IPAddress) Split(subnets uint) ResultIPAddresses {
if subnets == 0 || (1<<self.Prefix.Host_prefix()) <= subnets {
out := fmt.Sprintf("Value %s out of range", subnets)
out := fmt.Sprintf("Value %d out of range", subnets)
return &Errors{&out}
}
prefix, _ := self.Newprefix(subnets)
Expand Down
10 changes: 6 additions & 4 deletions go/ipaddress/ip_bits.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package ipaddress

import "math/big"
import "bytes"
import "fmt"
import (
"bytes"
"fmt"
"math/big"
)

type IpBits struct {
Version Family
Expand Down Expand Up @@ -94,7 +96,7 @@ func v6const() *IpBits {

func (ipb IpBits) String() string {
return fmt.Sprintf("IpBits:version:{%d},bits:{%d},part_bits:{%d},dns_bits:{%d},rev_domain:{%s},part_mod:{%s},host_ofs:{%s}",
ipb.Version, ipb.Bits, ipb.Part_bits, ipb.Dns_bits, ipb.Rev_domain, ipb.Part_mod, ipb.Host_ofs)
ipb.Version, ipb.Bits, ipb.Part_bits, ipb.Dns_bits, ipb.Rev_domain, ipb.Part_mod.String(), ipb.Host_ofs.String())
}

func reverse(numbers []uint16) []uint16 {
Expand Down
14 changes: 8 additions & 6 deletions go/ipaddress/ipv6_mapped.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package ipaddress

import "fmt"
import "strings"
import "bytes"
import "math/big"
import (
"bytes"
"fmt"
"math/big"
"strings"
)

// import "ipaddress"

Expand Down Expand Up @@ -99,7 +101,7 @@ func Ipv6MappedNew(str string) ResultIPAddress {
// let mapped: Option<IPAddress> = None;
netmask := ""
if o_netmask != nil {
netmask = fmt.Sprintf("/%s", o_netmask)
netmask = fmt.Sprintf("/%s", *o_netmask)
}
ipv4_str := split_colon[len(split_colon)-1]
if Is_valid_ipv4(ipv4_str) {
Expand Down Expand Up @@ -148,7 +150,7 @@ func Ipv6MappedNew(str string) ResultIPAddress {
p96bit := big.NewInt(0).Rsh(&ipv6.Host_address, 32)
if big.NewInt(0).Cmp(p96bit) != 0 {
// fmt.Printf("---4|%s", &rebuild_ipv6);
tmp := fmt.Sprintf("is not a mapped address:%s", rebuild_ipv6)
tmp := fmt.Sprintf("is not a mapped address:%s", rebuild_ipv6_str)
// fmt.Printf("Ipv6MappedNew-5:%s:%s\n", tmp, p96bit.String())
return &Error{&tmp}
}
Expand Down
10 changes: 6 additions & 4 deletions go/ipaddress/ipv6_mapped_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package ipaddress

import "testing"
import "math/big"
import "fmt"
import (
"fmt"
"math/big"
"testing"
)

type IPv6MappedTest struct {
ip IPAddress
Expand Down Expand Up @@ -51,7 +53,7 @@ func TestIpv6Mapped(tx *testing.T) {
for ip, u128 := range s.valid_mapped {
// fmt.Printf("-%s--%s\n", ip, u128);
if Parse(ip).IsErr() {
fmt.Printf("%s\n", Parse(ip).UnwrapErr())
fmt.Printf("%s\n", *Parse(ip).UnwrapErr())
}
t.assert_bool(true, Parse(ip).IsOk())
t.assert_bigint(u128, Parse(ip).Unwrap().Host_address)
Expand Down
2 changes: 1 addition & 1 deletion go/ipaddress/rle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Rle struct {
}

func (r *Rle) String() string {
return fmt.Sprintf("Rle:Part:{%d},Pos:{%d},Cnt:{%d},Max:{%d}",
return fmt.Sprintf("Rle:Part:{%d},Pos:{%d},Cnt:{%d},Max:{%t}",
r.Part, r.Pos, r.Cnt, r.Max)
}

Expand Down

0 comments on commit 2566658

Please sign in to comment.