{"modulePath":"github.com/utmstack/UTMStack/installer","version":"v0.0.0-20261203180808-4d12b9be42b1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Functions\n\n```go\nfunc CheckIfPathExist(path string) bool\n```\n\n```go\nfunc CheckIfServiceIsInstalled(serv string) (bool, error)\n```\n\n```go\nfunc CreatePathIfNotExist(path string) error\n```\n\n```go\nfunc DoReq[response any](url string, data []byte, method string, headers map[string]string, transCfg *http.Transport) (response, int, error)\n```\nDoReq sends an HTTP request and processes the response.\n\nThis function sends an HTTP request to the specified URL with the given method, data, and headers. It returns the response body unmarshalled into the specified response type, the HTTP status code, and an error if any occurred during the process.\n\nType Parameters:\n\n  - response: The type into which the response body will be unmarshalled.\n\nParameters:\n\n  - url: The URL to which the request is sent.\n  - data: The request payload as a byte slice.\n  - method: The HTTP method to use for the request (e.g., \"GET\", \"POST\").\n  - headers: A map of headers to include in the request.\n\nReturns:\n\n  - response: The response body unmarshalled into the specified type.\n  - int: The HTTP status code of the response.\n  - error: An error if any occurred during the request or response processing, otherwise nil.\n\n```go\nfunc Download(url, file string) error\n```\nDownload downloads the content from the specified URL and saves it to the specified file. It returns an error if any error occurs during the process.\n\nParameters:\n\n  - url: The URL from which to download the content.\n  - file: The path to the file where the content should be saved.\n\nReturns:\n\n  - error: An error object if an error occurs, otherwise nil.\n\n```go\nfunc GenerateCerts(folder string) error\n```\n\n```go\nfunc GenerateComplexSecret(size int) string\n```\nGenerateComplexSecret returns a random password that always contains at least one uppercase letter, one lowercase letter, one digit and one special character, so it passes strict password validators like OpenSearch's.\n\n```go\nfunc GenerateConfig(variables any, text, output string) error\n```\nGenerateConfig generates a configuration file from a text template.\n\nThe \\`variables\\` argument is a map of variables to be used in the template. The \\`text\\` argument is the text of the template. The \\`output\\` argument is the path to the output file.\n\nThe function returns an error if there is any problem generating the configuration file.\n\n```go\nfunc GenerateSecret(size int) string\n```\n\n```go\nfunc GetLock(v int, locksDir string) bool\n```\n\n```go\nfunc GetMainIP() (string, error)\n```\n\n```go\nfunc GetMainIPInAirGapMode() (string, error)\n```\n\n```go\nfunc GetMainIface(mainIP string) (string, error)\n```\n\n```go\nfunc GetMyPath() string\n```\n\n```go\nfunc GetStep() int\n```\n\n```go\nfunc MakeDir(mode os.FileMode, arg ...string) string\n```\n\n```go\nfunc Mode(mode string, options map[string]any) any\n```\n\n```go\nfunc ParseTemplate(text string, data any) (*bytes.Buffer, error)\n```\nParseTemplate parses a template and executes it with the given data.\n\ntext: The text of the template. data: The data to use to render the template.\n\nReturns: A bytes.Buffer containing the rendered template, or an error if parsing or execution failed.\n\n```go\nfunc PointerOf[t any](s t) *t\n```\n\n```go\nfunc ReadJson(fileName string, data any) error\n```\n\n```go\nfunc ReadYAML(path string, result any) error\n```\n\n```go\nfunc Remove(path string) error\n```\n\n```go\nfunc RemoveLocks(locks string, locksDir string) error\n```\n\n```go\nfunc RestartService(name string) error\n```\n\n```go\nfunc RunCmd(command string, arg ...string) error\n```\n\n```go\nfunc RunCmdWithOutput(command string, arg ...string) ([]string, error)\n```\n\n```go\nfunc RunEnvCmd(env []string, command string, arg ...string) error\n```\n\n```go\nfunc SetLock(v int, locksDir string) error\n```\n\n```go\nfunc StopService(name string) error\n```\n\n```go\nfunc UninstallService(name string) error\n```\n\n```go\nfunc WriteJSON(path string, data any) error\n```\n\n```go\nfunc WriteToFile(fileName string, body string) error\n```\n\n```go\nfunc WriteYAML(url string, data any) error\n```\n\n","path":"github.com/utmstack/UTMStack/installer/utils","name":"utils","synopsis":"","isRedistributable":true}
