Skip to content

Commit

Permalink
Merge pull request #15 from ldez/feat/documentation
Browse files Browse the repository at this point in the history
doc: improve readme
  • Loading branch information
sashamelentyev authored Jul 26, 2022
2 parents 75d571d + df4a32f commit d236fdb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,66 @@
# usestdlibvars

The Golang linter that detect possibility use variables/constants from stdlib
A linter that detect the possibility to use variables/constants from the Go standard library.

## Install

```console
```
go install github.com/sashamelentyev/usestdlibvars
```

## Usage

```console
$ usestdlibvars -h
usestdlibvars: Detect the possibility to use constants/variables from the stdlib.

Usage: usestdlibvars [-flag] [package]


Flags:
-V print version and exit
-all
no effect (deprecated)
-c int
display offending line with this many lines of context (default -1)
-cpuprofile string
write CPU profile to this file
-crypto-hash
suggest the use of crypto.Hash
-debug string
debug flags, any subset of "fpstv"
-fix
apply all suggested fixes
-flags
print analyzer flags in JSON
-http-method
suggest the use of http.MethodXX (default true)
-http-status-code
suggest the use of http.StatusXX (default true)
-json
emit JSON output
-memprofile string
write memory profile to this file
-source
no effect (deprecated)
-tags string
no effect (deprecated)
-test
indicates whether test files should be analyzed, too (default true)
-time-layout
suggest the use of time.Layout
-time-month
suggest the use of time.Month
-time-weekday
suggest the use of time.Weekday
-trace string
write trace log to this file
-v no effect (deprecated)

```

## Examples

```bash
usestdlibvars ./...
```
12 changes: 6 additions & 6 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func New() *analysis.Analyzer {

func flags() flag.FlagSet {
flags := flag.NewFlagSet("", flag.ExitOnError)
flags.Bool(HTTPMethodFlag, true, "")
flags.Bool(HTTPStatusCodeFlag, true, "")
flags.Bool(TimeWeekdayFlag, false, "")
flags.Bool(TimeMonthFlag, false, "")
flags.Bool(TimeLayoutFlag, false, "")
flags.Bool(CryptoHashFlag, false, "")
flags.Bool(HTTPMethodFlag, true, "suggest the use of http.MethodXX")
flags.Bool(HTTPStatusCodeFlag, true, "suggest the use of http.StatusXX")
flags.Bool(TimeWeekdayFlag, false, "suggest the use of time.Weekday")
flags.Bool(TimeMonthFlag, false, "suggest the use of time.Month")
flags.Bool(TimeLayoutFlag, false, "suggest the use of time.Layout")
flags.Bool(CryptoHashFlag, false, "suggest the use of crypto.Hash")
return *flags
}

Expand Down

0 comments on commit d236fdb

Please sign in to comment.