• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yitsushi / macpot / 4284291729

pending completion
4284291729

Pull #10

github

GitHub
Merge 8169ebedc into be03cc87c
Pull Request #10: Bump github.com/stretchr/testify from 1.8.1 to 1.8.2

180 of 192 relevant lines covered (93.75%)

10.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.24
/with_nic_from_ipv4.go
1
package macpot
2

3
import (
4
        "fmt"
5
        "strconv"
6
        "strings"
7
)
8

9
// WithNICFromIPv4 is an Option for New() that sets the generated MAC address with fixed
10
// NIC based on the provided IPv4 address. It uses the last 3 bytes of the
11
// address.
12
func WithNICFromIPv4(ip string) Option {
8✔
13
        parts := strings.Split(ip, ".")
8✔
14

8✔
15
        return func(mac *MAC) error {
16✔
16
                // We will skip the first part.
8✔
17
                if len(parts) != nicByteLength+1 {
10✔
18
                        return IPv4Error{Message: fmt.Sprintf("invalid IPv4 address: %s", ip)}
2✔
19
                }
2✔
20

21
                for idx := 0; idx < nicByteLength; idx++ {
23✔
22
                        value, err := strconv.ParseInt(parts[idx+1], base10, ipIntSize)
17✔
23
                        if err != nil {
18✔
24
                                return IPv4Error{Message: err.Error()}
1✔
25
                        }
1✔
26

27
                        if err := mac.SetOctet(ouiByteLength+idx, byte(value)); err != nil {
16✔
28
                                return err
×
29
                        }
×
30
                }
31

32
                return nil
5✔
33
        }
34
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc