Documentation
¶
Index ¶
- Variables
- func CloneRepoViaHTTP(path string, url string, repo string) error
- func CompareFile(file1Path string, file2Path string) (bool, error)
- func CreateDir(dirPath string) error
- func CreateFile(filePath string) error
- func DeleteFile(filePath string) error
- func DownloadFile(url string, urlFile string, outputFile string) (string, error)
- func FileEmpty(filePath string) bool
- func FileExist(filePath string) bool
- func FolderEmpty(filePath string) bool
- func GetCurrentUserInfo() (*user.User, error)
- func GetHostname() string
- func GetTomlConfig(filePath string) (*toml.Tree, error)
- func GetUserInfoById(userId int) (*user.User, error)
- func GetUserInfoByName(userName string) (*user.User, error)
- func GetVariable(key string) string
- func GoToDir(dirPath string) error
- func InstallFile(sourceFile, targetFile string) error
- func ParseApiResponse(body []byte) (string, error)
- func PolicyKitAuthentication()
- func ProgramInfo(only bool) string
- func RequestApi(url string) ([]byte, error)
- func RunCommand(command string, args []string) error
- func RunCommandGetResult(command string, args []string) (string, error)
- func SetVariable(key, value string) error
- func WriteFile(filePath string, content string) error
- func WriteTomlConfig(filePath string) (int64, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // chezmoi的依赖项 ChezmoiDependencies = "/usr/bin/chezmoi" ChezmoiConfig = fmt.Sprintf(chezmoiConfigFormat, chezmoiSourceDir, sep, chezmoiAutoCommit, sep, chezmoiAutoPush) ChezmoiConfigFile = home + "/.config/chezmoi/chezmoi.toml" // cobra的依赖项 CobraDependencies = goGOBIN + "/cobra-cli" CobraConfig = fmt.Sprintf(cobraConfigFormat, cobraAuthor, email, cobraLicense, cobraUseViper) CobraConfigFile = home + "/.cobra.yaml" // docker service和mirrors的依赖项 DockerDependencies = "/usr/bin/dockerd" DockerServiceConfig = fmt.Sprintf(dockerServiceConfigFormat, dockerServiceExecStart, dockerServiceDataRoot) DockerServiceConfigFile = "/etc/systemd/system/docker.service.d/override.conf" DockerMirrorsConfig = fmt.Sprintf(dockerMirrorsConfigFormat, sep, dockerMirrorsRegistryMirrors) DockerMirrorsConfigFile = "/etc/docker/daemon.json" // frpc的依赖项 FrpcDependencies = "/usr/bin/frpc" FrpcConfig = fmt.Sprintf(frpcConfigFormat, frpcRestart) FrpcConfigFile = "/etc/systemd/system/frpc.service.d/override.conf" // git的依赖项 GitDependencies = "/usr/bin/git" GitConfig = fmt.Sprintf(gitConfigFormat, sep, hostname, sep, email, sep, gitCoreEditor, sep, gitCoreAutoCRLF, sep, gitMergeTool, sep, gitColorUI, sep, gitPullRebase, sep, gitFilterLfsClean, sep, gitFilterLfsSmudge, sep, gitFilterLfsProcess, sep, gitFilterLfsRequired) GitConfigFile = home + "/.gitconfig" // go的依赖项 GoDependencies = "/usr/bin/go" GoConfig = fmt.Sprintf(goConfigFormat, goGO111MODULE, goGOBIN, goGOPATH, goGOCACHE, goGOMODCACHE) GoConfigFile = home + "/.config/go/env" // npm的依赖项 NpmDependencies = "/usr/bin/npm" NpmConfig = fmt.Sprintf(npmConfigFormat, npmRegistry) NpmConfigFile = home + "/.npmrc" // pip的依赖项 PipDependencies = "/usr/bin/pip" PipConfig = fmt.Sprintf(pipConfigFormat, pipIndexUrl, pipTrustedHost) PipConfigFile = home + "/.config/pip/pip.conf" // system-checkupdates timer和service的依赖项 SystemCheckupdatesDependencies = "/usr/local/bin/system-checkupdates" // >= 3.0.0-20230313.1 SystemCheckupdatesTimerConfig = fmt.Sprintf(systemCheckupdatesTimerConfigFormat, systemcheckupdatesTimerDescription, systemcheckupdatesTimerOnBootSec, systemcheckupdatesTimerOnUnitInactiveSec, systemcheckupdatesTimerAccuracySec, systemcheckupdatesTimerPersistent, systemcheckupdatesTimerWantedBy) SystemCheckupdatesTimerConfigFile = "/etc/systemd/system/system-checkupdates.timer" SystemCheckupdatesServiceConfig = fmt.Sprintf(systemCheckupdatesServiceConfigFormat, systemcheckupdatesServiceDescription, systemcheckupdatesServiceAfter, systemcheckupdatesServiceWants, systemcheckupdatesServiceType, systemcheckupdatesServiceExecStart) SystemCheckupdatesServiceConfigFile = "/etc/systemd/system/system-checkupdates.service" )
View Source
var UserInfo, _ = GetUserInfoByName(UserName)
用户信息
View Source
var UserName = func() string { if GetVariable("SUDO_USER") != "" { return GetVariable("SUDO_USER") } return GetVariable("USER") }()
用户名,当程序提权运行时,使用SUDO_USER变量获取提权前的用户名
Functions ¶
func CloneRepoViaHTTP ¶ added in v0.1.2
通过HTTP协议克隆仓库
func CompareFile ¶ added in v0.1.0
并发比较两个文件是否相同
func DownloadFile ¶ added in v0.3.0
通过HTTP协议下载文件
func GetTomlConfig ¶ added in v0.0.4
读取toml配置文件
func GetUserInfoById ¶ added in v0.8.4
根据ID获取用户信息
func GetUserInfoByName ¶ added in v0.8.4
根据用户名获取用户信息
func InstallFile ¶ added in v0.1.0
复制文件,如果文件存在则覆盖
func ParseApiResponse ¶ added in v0.2.9
解析API响应体,根据JSON数据解析后的类型选择数据提取方式
func PolicyKitAuthentication ¶ added in v0.1.0
func PolicyKitAuthentication()
func ProgramInfo ¶
func RunCommand ¶ added in v0.7.3
运行指定命令(命令无输出)
func RunCommandGetResult ¶ added in v0.0.5
运行指定命令并获取命令输出
func WriteTomlConfig ¶ added in v0.0.4
写入toml配置文件
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.