mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-30 06:16:37 +08:00
8ff017b5e8
下游 OpenFlare 的边缘守护进程与发布流程需要这些与业务无关的纯函数, 按上游/下游归属规约回流到平台层,避免下游在上游目录里长期携带本地文件: - version / version_compare:CompareVersions、ParseVersionInfo(版本区间比较) - network:GetIP、IsPrivateIPv4 - format / value / string / slice:Bytes2Size、Seconds2Time、Interface2String、 TrimStringFields、UniqueAndCleanStringSlice 与 IdentifiableTimeRecord 验证:go build 通过;go test ./... exit 0(48 包 ok); check_cordis_architecture.sh 0 violations;golangci-lint 0 issues;gofmt 干净。
23 lines
411 B
Go
23 lines
411 B
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
// Interface2String converts a string, int, or float64 value to its string representation.
|
|
func Interface2String(inter any) string {
|
|
switch v := inter.(type) {
|
|
case string:
|
|
return v
|
|
case int:
|
|
return strconv.Itoa(v)
|
|
case float64:
|
|
return fmt.Sprintf("%f", v)
|
|
}
|
|
return "Not Implemented"
|
|
}
|