feat: refactor go.mod.

This commit is contained in:
tx7do
2024-11-14 09:03:48 +08:00
parent 883b23dbbb
commit da4a21ce62
16 changed files with 2807 additions and 1701 deletions

14
utils/files.go Normal file
View File

@@ -0,0 +1,14 @@
package utils
import "os"
func PathExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return false
}

38
utils/service_info.go Normal file
View File

@@ -0,0 +1,38 @@
package utils
import "os"
type ServiceInfo struct {
Name string
Version string
Id string
Metadata map[string]string
}
func NewServiceInfo(name, version, id string) *ServiceInfo {
if id == "" {
id, _ = os.Hostname()
}
return &ServiceInfo{
Name: name,
Version: version,
Id: id,
Metadata: map[string]string{},
}
}
func (s *ServiceInfo) SetName(name string) {
s.Name = name
}
func (s *ServiceInfo) SetVersion(version string) {
s.Version = version
}
func (s *ServiceInfo) GetInstanceId() string {
return s.Id + "." + s.Name
}
func (s *ServiceInfo) SetMataData(k, v string) {
s.Metadata[k] = v
}