func ParsePTAgentConf(content string, agent *agent.Config, dsn *mysql.DSN) (string, error) { libDir := "" if content == "" { return libDir, nil } libDirRe := regexp.MustCompile(`lib\s*=(\S+)`) m := libDirRe.FindStringSubmatch(content) if len(m) > 1 { libDir = m[1] fmt.Printf("pt-agent lib dir: %s\n", libDir) } apiKeyRe := regexp.MustCompile(`^\s*api-key\s*=(\S+)`) m = apiKeyRe.FindStringSubmatch(content) if len(m) > 1 { agent.ApiKey = m[1] fmt.Printf("pt-agent API key: %s\n", agent.ApiKey) } socketRe := regexp.MustCompile(`socket\s*=(\S+)`) m = socketRe.FindStringSubmatch(content) if len(m) > 1 { dsn.Socket = m[1] fmt.Printf("pt-agent socket: %s\n", dsn.Socket) } return libDir, nil }