This article is a mirror article of machine translation, please click here to jump to the original article.

View: 8455|Reply: 0

Golang gets the MAC address of your local computer

[Copy link]
Posted on 9/29/2019 4:42:31 PM | | | |
Recently, when writing a small program, you need to get the MAC of the local computer to enter the next step; Then the golang library for a long time did not see a module that could directly obtain the MAC address of the computer; After Google and Baidu, I did not find that other netizens had written relevant content; Later, I went back to the Golang online doc to look through the help documentation;

According to my previous experience writing Python, I think it should be in the OS or net module; So I turned over all the functions of the OS and NET modules; Later, I saw in net.interfaces that the introduction returned a HardwareAddr; it seemed that there might be a joke, so I read the introduction of HardwareAddr; this thing can indeed get the MAC address of the computer;

The following code is used to get the MAC address of the local computer

The results of the run are as follows







Previous:The .NET MVC Web API returns JSON content, filtering properties with a value of null
Next:SQL Server 2016 does not have an administrative tool (SSMS) after installation is complete
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com