fix: issues

This commit is contained in:
Rogee
2024-12-05 11:32:00 +08:00
parent 9ddd3f61ec
commit c6313f234b
17 changed files with 206 additions and 396 deletions

View File

@@ -16,7 +16,7 @@ type UUIDMap struct {
Name string
}
func NewStore(path string) (*Store, error) {
func NewStore(path string) (Store, error) {
mapFile := filepath.Join(path, "map.json")
log.Infof("read in from: %s", mapFile)
if _, err := os.Stat(mapFile); err != nil {
@@ -38,10 +38,10 @@ func NewStore(path string) (*Store, error) {
return nil, errors.Wrapf(err, "unmarshal json: %s", mapFile)
}
return &store, nil
return store, nil
}
func (s *Store) Save(path string) error {
func (s Store) Save(path string) error {
mapFile := filepath.Join(path, "map.json")
b, err := json.Marshal(s)
if err != nil {
@@ -55,13 +55,13 @@ func (s *Store) Save(path string) error {
return nil
}
func (s *Store) Add(uuid, name string) {
*s = append(*s, UUIDMap{UUID: uuid, Name: name})
func (s Store) Add(uuid, name string) {
s = append(s, UUIDMap{UUID: uuid, Name: name})
}
func (s *Store) UUIDs() []string {
func (s Store) UUIDs() []string {
var uuids []string
for _, m := range *s {
for _, m := range s {
uuids = append(uuids, m.UUID)
}
@@ -69,8 +69,8 @@ func (s *Store) UUIDs() []string {
}
// Exists
func (s *Store) Exists(name string) bool {
for _, m := range *s {
func (s Store) Exists(name string) bool {
for _, m := range s {
if m.Name == name {
return true
}