Update to matoous/godox v1.0.

Dependency has to be pinned to commit hash since
tag is not a compatible semver supported by go.mod.
This commit is contained in:
Trevor Pounds 2019-09-29 12:33:48 -04:00
parent 7a93526db7
commit baff4ab35b
7 changed files with 27 additions and 11 deletions

2
go.mod

@ -21,7 +21,7 @@ require (
github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21
github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4
github.com/matoous/godox v0.0.0-20190910121045-032ad8106c86
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb // v1.0
github.com/mattn/go-colorable v0.1.2
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b

4
go.sum

@ -142,8 +142,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matoous/godox v0.0.0-20190910121045-032ad8106c86 h1:q6SrfsK4FojRnJ1j8+8OJzyq3g9Y1oSVyL6nYGJXXBk=
github.com/matoous/godox v0.0.0-20190910121045-032ad8106c86/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb h1:RHba4YImhrUVQDHUCe2BNSOz4tVy2yGyXhvYDvxGgeE=
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=

@ -3,6 +3,7 @@
*.dll
*.so
*.dylib
.idea
# Test binary, build with `go test -c`
*.test

@ -49,9 +49,12 @@ issues:
- goconst
- dupl
- path: api/v1/
- path: fixtures
linters:
- dupl
- gocritic
- varcheck
- deadcode
- unused
run:
modules-download-mode: readonly

@ -1,13 +1,16 @@
GoDoX
===
[![Build Status](https://travis-ci.org/matoous/godox.svg?branch=master)](https://travis-ci.org/matoous/godox)
[![Tests](https://github.com/matoous/godox/workflows/.github/workflows/test.yml/badge.svg)](https://github.com/matoous/godox/actions)
[![Lint](https://github.com/matoous/godox/workflows/.github/workflows/lint.yml/badge.svg)](https://github.com/matoous/godox/actions)
[![GoDoc](https://godoc.org/github.com/matoous/godox?status.svg)](https://godoc.org/github.com/matoous/godox)
[![Go Report Card](https://goreportcard.com/badge/github.com/matoous/godox)](https://goreportcard.com/report/github.com/matoous/godox)
[![GitHub issues](https://img.shields.io/github/issues/matoous/godox.svg)](https://github.com/matoous/godox/issues)
[![License](https://img.shields.io/badge/license-MIT%20License-blue.svg)](https://github.com/matoous/godox/LICENSE)
GoDoX extracts comments from Go code based on keywords.
GoDoX extracts comments from Go code based on keywords. This repository is fork of https://github.com/766b/godox
but a lot of code has changed, this repository is updated and the code was adjusted for better integration with
https://github.com/golangci/golangci-lint.
Installation
---

@ -47,12 +47,19 @@ func getMessages(c *ast.Comment, fset *token.FileSet, keywords []string) []Messa
for _, kw := range keywords {
if bytes.EqualFold([]byte(kw), sComment[0:len(kw)]) {
pos := fset.Position(c.Pos())
// trim the comment
if len(sComment) > 40 {
sComment = []byte(fmt.Sprintf("%s...", sComment[:40]))
}
comments = append(comments, Message{
Pos: pos,
Message: fmt.Sprintf("%s:%d: Line contains %s: \"%s\"", filepath.Join(pos.Filename), pos.Line+lineNum, strings.Join(keywords, "/"), sComment),
Pos: pos,
Message: fmt.Sprintf(
"%s:%d: Line contains %s: \"%s\"",
filepath.Join(pos.Filename),
pos.Line+lineNum,
strings.Join(keywords, "/"),
sComment,
),
})
break
}
@ -61,8 +68,10 @@ func getMessages(c *ast.Comment, fset *token.FileSet, keywords []string) []Messa
return comments
}
// Run runs the godox linter on given file.
// Godox searches for comments starting with given keywords and reports them.
func Run(file *ast.File, fset *token.FileSet, keywords ...string) []Message {
if keywords == nil || len(keywords) == 0 {
if len(keywords) == 0 {
keywords = defaultKeywords
}
var messages []Message

2
vendor/modules.txt vendored

@ -102,7 +102,7 @@ github.com/kisielk/gotool/internal/load
github.com/konsorten/go-windows-terminal-sequences
# github.com/magiconair/properties v1.8.0
github.com/magiconair/properties
# github.com/matoous/godox v0.0.0-20190910121045-032ad8106c86
# github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb
github.com/matoous/godox
# github.com/mattn/go-colorable v0.1.2
github.com/mattn/go-colorable