Skip to content

Commit 5990b2e

Browse files
committed
init
0 parents  commit 5990b2e

File tree

14 files changed

+891
-0
lines changed

14 files changed

+891
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
9+
[*.go]
10+
indent_style = tab
11+
indent_size = 4

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Go template
3+
# Binaries for programs and plugins
4+
*.exe
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, build with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool, specifically when used with LiteIDE
13+
*.out
14+
15+
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
16+
.glide/
17+
18+
.idea/goser.iml
19+
.idea/modules.xml
20+
.idea/workspace.xml
21+
22+
.idea/**/**
23+
24+
.DS_Store
25+
26+
zc
27+
28+
bin
29+
30+
.env
31+
32+
vendor
33+
34+
coverage.txt
35+
36+
dist
37+
38+
.envc
39+
40+
toc
41+
42+
solve
43+
44+
.leetcode.json

.golangci.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
run:
2+
concurrency: 4
3+
4+
# timeout for analysis, e.g. 30s, 5m, default is 1m
5+
deadline: 10m
6+
7+
# which dirs to skip: they won't be analyzed;
8+
# can use regexp here: generated.*, regexp is applied on full path;
9+
# default value is empty list, but next dirs are always skipped independently
10+
# from this option's value:
11+
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
12+
skip-dirs:
13+
- genfiles$
14+
- vendor$
15+
16+
# which files to skip: they will be analyzed, but issues from them
17+
# won't be reported. Default value is empty list, but there is
18+
# no need to include all autogenerated files, we confidently recognize
19+
# autogenerated files. If it's not please let us know.
20+
skip-files:
21+
- ".*\\.pb\\.go"
22+
- ".*\\.gen\\.go"
23+
24+
linters:
25+
enable-all: true
26+
disable:
27+
- depguard
28+
- dupl
29+
- gochecknoglobals
30+
- gochecknoinits
31+
- goconst
32+
- gocyclo
33+
- gosec
34+
- nakedret
35+
- prealloc
36+
- scopelint
37+
fast: false
38+
39+
linters-settings:
40+
errcheck:
41+
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
42+
# default is false: such cases aren't reported by default.
43+
check-type-assertions: false
44+
45+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
46+
# default is false: such cases aren't reported by default.
47+
check-blank: false
48+
govet:
49+
# report about shadowed variables
50+
check-shadowing: false
51+
golint:
52+
# minimal confidence for issues, default is 0.8
53+
min-confidence: 0.0
54+
gofmt:
55+
# simplify code: gofmt with `-s` option, true by default
56+
simplify: true
57+
goimports:
58+
# put imports beginning with prefix after 3rd-party packages;
59+
# it's a comma-separated list of prefixes
60+
local-prefixes: istio.io/
61+
maligned:
62+
# print struct with more effective memory layout or not, false by default
63+
suggest-new: true
64+
dupl:
65+
# tokens count to trigger issue, 150 by default
66+
threshold: 100
67+
goconst:
68+
# minimal length of string constant, 3 by default
69+
min-len: 3
70+
# minimal occurrences count to trigger, 3 by default
71+
min-occurrences: 3
72+
misspell:
73+
# Correct spellings using locale preferences for US or UK.
74+
# Default is to use a neutral variety of English.
75+
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
76+
locale: US
77+
lll:
78+
# max line length, lines longer will be reported. Default is 120.
79+
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
80+
line-length: 160
81+
# tab width in spaces. Default to 1.
82+
tab-width: 1
83+
unused:
84+
# treat code as a program (not a library) and report unused exported identifiers; default is false.
85+
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
86+
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
87+
# with golangci-lint call it on a directory with the changed file.
88+
check-exported: false
89+
unparam:
90+
# call graph construction algorithm (cha, rta). In general, use cha for libraries,
91+
# and rta for programs with main packages. Default is cha.
92+
algo: cha
93+
94+
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
95+
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
96+
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
97+
# with golangci-lint call it on a directory with the changed file.
98+
check-exported: false
99+
gocritic:
100+
disabled-checks:
101+
- ifElseChain
102+
- singleCaseSwitch
103+
- appendAssign
104+
105+
issues:
106+
# List of regexps of issue texts to exclude, empty list by default.
107+
# But independently from this option we use default exclude patterns,
108+
# it can be disabled by `exclude-use-default: false`. To list all
109+
# excluded by default patterns execute `golangci-lint run --help`
110+
exclude:
111+
- composite literal uses unkeyed fields
112+
113+
exclude-rules:
114+
# Exclude some linters from running on test files.
115+
- path: _test\.go$|^tests/|^samples/
116+
linters:
117+
- errcheck
118+
- maligned
119+
120+
# Independently from option `exclude` we use default exclude patterns,
121+
# it can be disabled by this option. To list all
122+
# excluded by default patterns execute `golangci-lint run --help`.
123+
# Default value for this option is true.
124+
exclude-use-default: true
125+
126+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
127+
max-per-linter: 0
128+
129+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
130+
max-same-issues: 0

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) zcong1993 <zhangcong1992@gmail.com> (https://github.com/zcong1993)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# leetcode-tool
2+
<!--
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/zcong1993/leetcode-tool)](https://goreportcard.com/report/github.com/zcong1993/leetcode-tool)
4+
-->
5+
6+
> my go grpc project
7+
8+
## License
9+
10+
MIT &copy; zcong1993

circle.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
# CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/
6+
- image: circleci/golang:1.10
7+
8+
working_directory: /go/src/github.com/zcong1993/leetcode-tool
9+
10+
steps:
11+
- checkout
12+
- run:
13+
name: build
14+
command: make build

cmd/main.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
8+
"github.com/zcong1993/leetcode-tool/cmd/new"
9+
"github.com/zcong1993/leetcode-tool/cmd/tags"
10+
"github.com/zcong1993/leetcode-tool/cmd/update"
11+
"github.com/zcong1993/leetcode-tool/pkg/leetcode"
12+
13+
"gopkg.in/alecthomas/kingpin.v2"
14+
)
15+
16+
var (
17+
app = kingpin.New("algo", "A command-line tool for algo-go repo.")
18+
19+
updateCmd = app.Command("update", "Update readme.")
20+
21+
newCmd = app.Command("new", "Init a new leetcode problem.")
22+
number = newCmd.Arg("number", "problem number").Required().String()
23+
lang = newCmd.Flag("lang", "language").String()
24+
25+
metaCmd = app.Command("meta", "Show problem meta by number.")
26+
metaNumber = metaCmd.Arg("number", "problem number").Required().String()
27+
28+
tagsCmd = app.Command("tags", "Update tag toc files.")
29+
)
30+
31+
func showMeta(number string) {
32+
meta, err := leetcode.GetMetaByNumber(number)
33+
if err != nil {
34+
log.Fatal(err)
35+
}
36+
meta.Content = ""
37+
meta.Code = ""
38+
meta.CodeSnippets = ""
39+
fmt.Printf("%+v\n", meta)
40+
}
41+
42+
func main() {
43+
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
44+
case updateCmd.FullCommand():
45+
update.Run()
46+
case newCmd.FullCommand():
47+
new.Run(*number, *lang)
48+
case metaCmd.FullCommand():
49+
showMeta(*metaNumber)
50+
case tagsCmd.FullCommand():
51+
tags.Run()
52+
}
53+
}

0 commit comments

Comments
 (0)