Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6130d8d

Browse files
author
Shuo
authored
Merge pull request #704 from openset/develop
Add: comment
2 parents cb55772 + 7c379a7 commit 6130d8d

30 files changed

+143
-94
lines changed

‎internal/base/base.go‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ import (
1313
"sync"
1414
)
1515

16-
// CmdName
16+
// CmdName - base.CmdName
1717
const CmdName = "leetcode"
1818

19+
// base var
1920
var (
2021
Commands []*Command
2122
Mutex sync.Mutex
2223
)
2324

24-
// Command
25+
// Command - base.Command
2526
type Command struct {
2627
Run func(cmd *Command, args []string)
2728
UsageLine string
@@ -30,6 +31,7 @@ type Command struct {
3031
Hidden bool
3132
}
3233

34+
// Name - base.Name
3335
func (c *Command) Name() string {
3436
name := c.UsageLine
3537
if i := strings.Index(name, " "); i > 0 {
@@ -38,16 +40,19 @@ func (c *Command) Name() string {
3840
return name
3941
}
4042

43+
// Usage - base.Usage
4144
func (c *Command) Usage() {
4245
fmt.Printf("usage: %s %s\n\n", CmdName, c.UsageLine)
4346
fmt.Printf("Run '%s help %s' for details.\n", CmdName, c.Name())
4447
}
4548

49+
// UsageHelp - base.UsageHelp
4650
func (c *Command) UsageHelp() {
4751
fmt.Printf("usage: %s %s\n\n", CmdName, c.UsageLine)
4852
fmt.Println(c.Long)
4953
}
5054

55+
// Usage - base.Usage
5156
func Usage() {
5257
fmt.Printf("%s is a tool for managing leetcode source code.\n\n", CmdName)
5358
fmt.Println("Usage:")
@@ -61,10 +66,11 @@ func Usage() {
6166
fmt.Printf("\nUse \"%s help <command>\" for more information about a command.\n", CmdName)
6267
}
6368

69+
// FilePutContents - base.FilePutContents
6470
func FilePutContents(filename string, data []byte) []byte {
6571
ext := filepath.Ext(filename)
6672
if strings.EqualFold(ext, ".json") {
67-
data = JsonIndent(data)
73+
data = JSONIndent(data)
6874
}
6975
if len(data) > 0 {
7076
filename = getFilePath(filename)
@@ -74,7 +80,8 @@ func FilePutContents(filename string, data []byte) []byte {
7480
return data
7581
}
7682

77-
func JsonIndent(src []byte) []byte {
83+
// JSONIndent - base.JSONIndent
84+
func JSONIndent(src []byte) []byte {
7885
if !json.Valid(src) {
7986
return nil
8087
}
@@ -93,12 +100,14 @@ func getFilePath(filename string) string {
93100
return filename
94101
}
95102

103+
// CheckErr - base.CheckErr
96104
func CheckErr(err error) {
97105
if err != nil {
98106
log.Fatalln(err)
99107
}
100108
}
101109

110+
// AuthInfo - base.AuthInfo
102111
func AuthInfo(cmd string) string {
103112
format := "<!--|This file generated by command(leetcode %s); DO NOT EDIT.%s|-->\n"
104113
format += "<!--+----------------------------------------------------------------------+-->\n"

‎internal/build/build.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/openset/leetcode/internal/version"
1414
)
1515

16+
// CmdBuild - build.CmdBuild
1617
var CmdBuild = &base.Command{
1718
Run: runBuild,
1819
UsageLine: "build",

‎internal/clean/clean.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/openset/leetcode/internal/leetcode"
77
)
88

9+
// CmdClean - clean.CmdClean
910
var CmdClean = &base.Command{
1011
Run: runClean,
1112
UsageLine: "clean",

‎internal/client/client.go‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func init() {
2525
}
2626
}
2727

28+
// Get - client.Get
2829
func Get(url string) []byte {
2930
if resp, err := http.Get(url); err == nil {
3031
defer resp.Body.Close()
@@ -35,7 +36,8 @@ func Get(url string) []byte {
3536
return nil
3637
}
3738

38-
func PostJson(url, jsonStr string) []byte {
39+
// PostJSON - client.PostJSON
40+
func PostJSON(url, jsonStr string) []byte {
3941
if resp, err := http.Post(url, "application/json", strings.NewReader(jsonStr)); err == nil {
4042
defer resp.Body.Close()
4143
body, err := ioutil.ReadAll(resp.Body)

‎internal/description/description.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/openset/leetcode/internal/leetcode"
1010
)
1111

12+
// CmdDescription - description.CmdDescription
1213
var CmdDescription = &base.Command{
1314
Run: runDescription,
1415
UsageLine: "description",
@@ -29,7 +30,7 @@ func runDescription(cmd *base.Command, args []string) {
2930
}
3031
problems := leetcode.ProblemsAll()
3132
for _, problem := range problems.StatStatusPairs {
32-
fmt.Println(problem.Stat.FrontendQuestionId, "\t"+problem.Stat.QuestionTitle)
33+
fmt.Println(problem.Stat.FrontendQuestionID, "\t"+problem.Stat.QuestionTitle)
3334
wg.Add(1)
3435
jobs <- problem
3536
}

‎internal/help/help.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/openset/leetcode/internal/base"
88
)
99

10+
// CmdHelp - help.CmdHelp
1011
var CmdHelp = &base.Command{
1112
Run: runHelp,
1213
UsageLine: "help [command]",

‎internal/helper/helper.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/openset/leetcode/internal/base"
99
)
1010

11+
// CmdHelper - help.CmdHelper
1112
var CmdHelper = &base.Command{
1213
Run: runHelper,
1314
UsageLine: "helper",

‎internal/kit/list_node.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package kit
22

3-
// Definition for singly-linked list.
3+
// ListNode - Definition for singly-linked list.
44
type ListNode struct {
55
Val int
66
Next *ListNode
77
}
88

9-
// convert *ListNode to []int
9+
// ListNode2SliceInt - convert *ListNode to []int
1010
func ListNode2SliceInt(l *ListNode) (s []int) {
1111
for l != nil {
1212
s = append(s, l.Val)
@@ -15,7 +15,7 @@ func ListNode2SliceInt(l *ListNode) (s []int) {
1515
return
1616
}
1717

18-
// convert []int to *ListNode
18+
// SliceInt2ListNode - convert []int to *ListNode
1919
func SliceInt2ListNode(s []int) *ListNode {
2020
l := &ListNode{}
2121
t := l

‎internal/kit/tree_node.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ package kit
22

33
import "math"
44

5+
// NULL null
56
var NULL = math.MinInt32
67

7-
// Definition for a binary tree node.
8+
// TreeNode - Definition for a binary tree node.
89
type TreeNode struct {
910
Val int
1011
Left *TreeNode
1112
Right *TreeNode
1213
}
1314

14-
// convert []int to *TreeNode
15+
// SliceInt2TreeNode - convert []int to *TreeNode
1516
func SliceInt2TreeNode(s []int) *TreeNode {
1617
l := len(s)
1718
if l == 0 {
@@ -39,7 +40,7 @@ func SliceInt2TreeNode(s []int) *TreeNode {
3940
return tree
4041
}
4142

42-
// convert *TreeNode to []int
43+
// TreeNode2SliceInt - convert *TreeNode to []int
4344
func TreeNode2SliceInt(t *TreeNode) (s []int) {
4445
if t != nil {
4546
queue := []*TreeNode{t}

‎internal/leetcode/base.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ import (
1414
"github.com/openset/leetcode/internal/client"
1515
)
1616

17+
// leetcode var
1718
var (
1819
authInfo = base.AuthInfo
1920
checkErr = base.CheckErr
2021
filePutContents = base.FilePutContents
21-
jsonIndent = base.JsonIndent
22+
jsonIndent = base.JSONIndent
2223
LockStr = " 🔒"
2324
translationSet = make(map[int]string)
2425
)
2526

2627
func graphQLRequest(graphQL, jsonStr, filename string, days int, v interface{}) {
2728
data := remember(filename, days, func() []byte {
28-
return client.PostJson(graphQL, jsonStr)
29+
return client.PostJSON(graphQL, jsonStr)
2930
})
3031
jsonDecode(data, &v)
3132
}
@@ -63,6 +64,7 @@ func getCachePath(f string) string {
6364
return filepath.Join(dir, ".leetcode", f)
6465
}
6566

67+
// Clean - leetcode.Clean
6668
func Clean() {
6769
dir := getCachePath("")
6870
err := os.RemoveAll(dir)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /