com_net

package
v0.0.0-...-3d4fdec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package com_net provide function about net

Index

Examples

Constants

View Source
const (
	En0 = "en0"
)

Variables

This section is empty.

Functions

func GetOutboundIP

func GetOutboundIP() (net.IP, error)

GetOutboundIP need network Get preferred outbound ip of this machine

Example
package main

import (
	"fmt"

	"github.com/zhangxiaofeng05/com/com_net"
)

func main() {
	ip, err := com_net.GetOutboundIP()
	if err != nil {
		panic(err)
	}
	fmt.Println(ip.String())
	// 192.168.31.147
}
Output:

func GetPhysicalAddress

func GetPhysicalAddress() (string, error)
Example
package main

import (
	"fmt"

	"github.com/zhangxiaofeng05/com/com_net"
)

func main() {
	physicalAddress, err := com_net.GetPhysicalAddress()
	if err != nil {
		panic(err)
	}
	fmt.Printf("physicalAddress: %v", physicalAddress)
	// mac: b1:bd:84:51:1c:bc
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL