1 Star 1 Fork 0

wulala乌啦啦/hwpack

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
utils.go 961 Bytes
一键复制 编辑 原始数据 按行查看 历史
wulala乌啦啦 提交于 2021-09-06 16:18 . 1、修改nmcli的依赖
package nmcli
import (
"bufio"
"io"
"io/ioutil"
"net"
"os"
"strconv"
"strings"
)
func StringIpToInt(ipstring string) int {
ipSegs := strings.Split(ipstring, ".")
var ipInt int = 0
if len(ipSegs) == 4 {
var ipSeg [4]int
ipSeg[0], _ = strconv.Atoi(ipSegs[0])
ipSeg[1], _ = strconv.Atoi(ipSegs[1])
ipSeg[2], _ = strconv.Atoi(ipSegs[2])
ipSeg[3], _ = strconv.Atoi(ipSegs[3])
ipInt, _ = net.IPv4Mask(byte(ipSeg[0]), byte(ipSeg[1]), byte(ipSeg[2]), byte(ipSeg[3])).Size()
}
return ipInt
}
// SaveFile saves file at given path
func SaveFile(filepath string, file []byte, permissions int) error {
return ioutil.WriteFile(filepath, file, os.FileMode(permissions))
}
// GetStdoutText reads out and concats string from io.Reader
func GetStdoutText(r io.Reader) (stdout []string) {
scanner := bufio.NewScanner(r)
for scanner.Scan() {
if lineOut := scanner.Text(); lineOut != "" {
stdout = append(stdout, lineOut)
}
}
return stdout
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wulalade/hwpack.git
git@gitee.com:wulalade/hwpack.git
wulalade
hwpack
hwpack
4a210dae89ef

搜索帮助

0d507c66 1850385 C8b1a773 1850385