mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 07:10:29 +08:00
Go: merge duplicate codes (#16783)
### Summary 1. merge heartbeat function. 2. introduce all environments --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -21,6 +21,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"ragflow/internal/common"
|
||||
|
||||
//"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -482,7 +484,7 @@ Commands:
|
||||
|
||||
// HistoryFile returns the path to the history file
|
||||
func HistoryFile() string {
|
||||
return os.Getenv("HOME") + "/" + historyFileName
|
||||
return common.GetEnv(common.EnvHome) + "/" + historyFileName
|
||||
}
|
||||
|
||||
const historyFileName = ".ragflow_cli_history"
|
||||
|
||||
@@ -19,8 +19,8 @@ package source
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"ragflow/internal/common"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -117,9 +117,9 @@ func (r *SourceResolver) Resolve(ref string) (SkillSource, string, error) {
|
||||
|
||||
// getHomeDir returns the user's home directory
|
||||
func getHomeDir() (string, error) {
|
||||
home := os.Getenv("HOME")
|
||||
home := common.GetEnv(common.EnvHome)
|
||||
if home == "" {
|
||||
home = os.Getenv("USERPROFILE")
|
||||
home = common.GetEnv(common.EnvUserProfile)
|
||||
}
|
||||
if home == "" {
|
||||
return "", fmt.Errorf("cannot determine home directory")
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"ragflow/internal/common"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -79,10 +80,10 @@ func (a *sourceHTTPClientAdapter) Get(url string) (*http.Response, error) {
|
||||
// NewInstallSkillCommand creates a new install-skill command handler
|
||||
func NewInstallSkillCommand(client HTTPClientInterface, fileProvider *FileProvider, skillProvider Provider) *SkillInstallCommand {
|
||||
// Log proxy settings
|
||||
if httpProxy := os.Getenv("http_proxy"); httpProxy != "" {
|
||||
if httpProxy := common.GetEnv(common.EnvHttpHTTPProxy); httpProxy != "" {
|
||||
fmt.Printf("Using HTTP proxy: %s\n", httpProxy)
|
||||
}
|
||||
if httpsProxy := os.Getenv("https_proxy"); httpsProxy != "" {
|
||||
if httpsProxy := common.GetEnv(common.EnvHttpHTTPSProxy); httpsProxy != "" {
|
||||
fmt.Printf("Using HTTPS proxy: %s\n", httpsProxy)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user