Skip to content

Commit 0e37042

Browse files
author
Shuo
committed
A: v1.6.1
1 parent f9b69bc commit 0e37042

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

internal/base/base.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"path/filepath"
1212
"strings"
13-
"sync"
1413
)
1514

1615
// CmdName - base.CmdName
@@ -19,11 +18,8 @@ const (
1918
URL = "https://github.com/openset/leetcode/tree/master"
2019
)
2120

22-
// base var
23-
var (
24-
Commands []*Command
25-
Mutex sync.Mutex
26-
)
21+
// Commands - base.Commands
22+
var Commands []*Command
2723

2824
// Command - base.Command
2925
type Command struct {

internal/leetcode/topic_tag.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99
"regexp"
1010
"sort"
1111
"strconv"
12+
"sync"
1213

13-
"github.com/openset/leetcode/internal/base"
1414
"github.com/openset/leetcode/internal/client"
1515
)
1616

1717
var (
18+
mu sync.Mutex
1819
initTags []TagType
1920
tagsFile = filepath.Join("tag", "tags.json")
2021
)
@@ -135,10 +136,10 @@ func GetTopicTag(slug string) (tt TopicTagType) {
135136
}
136137

137138
func saveTags(tags []TagType) {
138-
base.Mutex.Lock()
139+
mu.Lock()
140+
defer mu.Unlock()
139141
tags = append(GetTags(), tags...)
140142
filePutContents(tagsFile, jsonEncode(tagsUnique(tags)))
141-
base.Mutex.Unlock()
142143
}
143144

144145
func tagsUnique(tags []TagType) []TagType {

internal/version/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/openset/leetcode/internal/base"
99
)
1010

11-
const version = "1.6.0"
11+
const version = "1.6.1"
1212

1313
// CmdVersion - version.CmdVersion
1414
var CmdVersion = &base.Command{

0 commit comments

Comments
 (0)