diff options
author | Gusted <williamzijl7@hotmail.com> | 2021-11-14 08:11:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-14 10:11:49 +0200 |
commit | d2163df6a0d6b9663a65438c1d960ea4ab5c2df0 (patch) | |
tree | 821ab5acde9a8f382db637b83f0b3ae1c1f3c6f5 /cmd/docs.go | |
parent | 8eddb755086f84c8c1168447391ac04a3a6b7702 (diff) | |
download | gitea-d2163df6a0d6b9663a65438c1d960ea4ab5c2df0.tar.gz gitea-d2163df6a0d6b9663a65438c1d960ea4ab5c2df0.zip |
Fix offBy1 errors (#17606)
* Fix offBy1 errors
- Partially resolves #17596
- Resolve errors from go-critic `offBy1: Index() can return -1; maybe
you wanted to do Index()+1`.
* Match golang spec
* Remove comments
* Update migrations.go
* Apply suggestions from code review
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'cmd/docs.go')
-rw-r--r-- | cmd/docs.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/docs.go b/cmd/docs.go index 52233c7ac8..073c574973 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -43,7 +43,11 @@ func runDocs(ctx *cli.Context) error { // Clean up markdown. The following bug was fixed in v2, but is present in v1. // It affects markdown output (even though the issue is referring to man pages) // https://github.com/urfave/cli/issues/1040 - docs = docs[strings.Index(docs, "#"):] + firstHashtagIndex := strings.Index(docs, "#") + + if firstHashtagIndex > 0 { + docs = docs[firstHashtagIndex:] + } } out := os.Stdout |