summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Maiocchi <dmaiocchi@suse.com>2017-11-10 19:36:03 +0100
committerDario Maiocchi <dmaiocchi@suse.com>2017-11-16 11:26:28 +0100
commit56e399a1db9a371f2730f7ebf7513a3a544e0530 (patch)
tree6d8d471564881641056774707562f6183fb5bbe4
parent4a6eb4f8fe6addef884ffa2e382f52ee235e3697 (diff)
downloadterraform-provider-libvirt-56e399a1db9a371f2730f7ebf7513a3a544e0530.tar
terraform-provider-libvirt-56e399a1db9a371f2730f7ebf7513a3a544e0530.tar.gz
fix golint on utils_net.go
-rw-r--r--libvirt/utils_net.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/libvirt/utils_net.go b/libvirt/utils_net.go
index 8cadcc9a..e39ce55d 100644
--- a/libvirt/utils_net.go
+++ b/libvirt/utils_net.go
@@ -14,7 +14,7 @@ import (
const (
maxIfaceNum = 100
)
-
+// RandomMACAddress mac random
func RandomMACAddress() (string, error) {
buf := make([]byte, 6)
_, err := rand.Read(buf)
@@ -35,7 +35,7 @@ func RandomMACAddress() (string, error) {
return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]), nil
}
-
+// RandomPort return randomport
func RandomPort() int {
const minPort = 1024
const maxPort = 65535
@@ -44,6 +44,7 @@ func RandomPort() int {
return rand.Intn(maxPort-minPort) + minPort
}
+// FreeNetworkInterface free network interface
func FreeNetworkInterface(basename string) (string, error) {
for i := 0; i < maxIfaceNum; i++ {
ifaceName := fmt.Sprintf("%s%d", basename, i)
@@ -74,7 +75,7 @@ func NetworkRange(network *net.IPNet) (net.IP, net.IP) {
type fileWebServer struct {
Dir string
Port int
- Url string
+ URL string
server *http.Server
}
@@ -87,7 +88,7 @@ func (fws *fileWebServer) Start() error {
fws.Dir = dir
fws.Port = RandomPort()
- fws.Url = fmt.Sprintf("http://127.0.0.1:%d", fws.Port)
+ fws.URL = fmt.Sprintf("http://127.0.0.1:%d", fws.Port)
handler := http.NewServeMux()
handler.Handle("/", http.FileServer(http.Dir(dir)))
@@ -113,7 +114,7 @@ func (fws *fileWebServer) AddFile(content []byte) (string, *os.File, error) {
}
}
- return fmt.Sprintf("%s/%s", fws.Url, path.Base(tmpfile.Name())), tmpfile, nil
+ return fmt.Sprintf("%s/%s", fws.URL, path.Base(tmpfile.Name())), tmpfile, nil
}
func (fws *fileWebServer) Stop() {