安装过程中可以选择自动在本机安装MySQL

This commit is contained in:
刘祥超
2023-03-11 18:52:40 +08:00
parent 2546676f6a
commit 7e85555ba7
22 changed files with 1287 additions and 164 deletions

View File

@@ -0,0 +1,37 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package utils
import (
"os"
"path/filepath"
"strconv"
"strings"
)
const (
ProcDir = "/proc"
)
func FindPidWithName(name string) int {
// process name
commFiles, err := filepath.Glob(ProcDir + "/*/comm")
if err != nil {
return 0
}
for _, commFile := range commFiles {
data, err := os.ReadFile(commFile)
if err != nil {
continue
}
if strings.TrimSpace(string(data)) == name {
var pieces = strings.Split(commFile, "/")
var pid = pieces[len(pieces)-2]
pidInt, _ := strconv.Atoi(pid)
return pidInt
}
}
return 0
}