Skip to content

Commit

Permalink
chore: 更新依赖库
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Jun 2, 2022
1 parent 3c27f8b commit 81230bd
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 92 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
go: ['1.18.0-beta2']
go: ['1.18.x']

steps:

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [unreleased]

## [v7.2.4]

### Changed

- 仅支持 go1.18 版本;

## [v7.2.3]

### Added
Expand Down
12 changes: 3 additions & 9 deletions apidoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,13 @@ type Config = build.Config
// 如果不调用此函数,则默认会采用 internal/locale.DefaultLocaleID 的值。
// 如果想采用当前系统的本地化信息,可以使用
// github.com/issue9/localeutil.SystemLanguageTag 函数。
func SetLocale(tag language.Tag) {
locale.SetTag(tag)
}
func SetLocale(tag language.Tag) { locale.SetTag(tag) }

// Locale 获取当前设置的本地化 ID
func Locale() language.Tag {
return locale.Tag()
}
func Locale() language.Tag { return locale.Tag() }

// Locales 返回当前所有支持的本地化信息
func Locales() []language.Tag {
return locale.Tags()
}
func Locales() []language.Tag { return locale.Tags() }

// Version 当前程序的版本号
//
Expand Down
8 changes: 2 additions & 6 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ func (r Range) Equal(v Range) bool {
}

// IsEmpty 表示 Range 表示的范围长度为空
func (r Range) IsEmpty() bool {
return r.End == r.Start
}
func (r Range) IsEmpty() bool { return r.End == r.Start }

// Contains 是否包含了 p 这个点
func (r Range) Contains(p Position) bool {
Expand All @@ -83,9 +81,7 @@ func (r Range) Contains(p Position) bool {
}

// Loc 返回当前的范围
func (l Location) Loc() Location {
return l
}
func (l Location) Loc() Location { return l }

// Contains l 是否包含 pos 这个点
func (l Location) Contains(uri URI, pos Position) bool {
Expand Down
16 changes: 4 additions & 12 deletions core/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,13 @@ func (h *MessageHandler) Locale(t MessageType, key message.Reference, val ...int
}

// Error 发送错误类型的值
func (h *MessageHandler) Error(err interface{}) {
h.Message(Erro, err)
}
func (h *MessageHandler) Error(err interface{}) { h.Message(Erro, err) }

// Warning 发送错误类型的值
func (h *MessageHandler) Warning(err interface{}) {
h.Message(Warn, err)
}
func (h *MessageHandler) Warning(err interface{}) { h.Message(Warn, err) }

// Success 发送错误类型的值
func (h *MessageHandler) Success(err interface{}) {
h.Message(Succ, err)
}
func (h *MessageHandler) Success(err interface{}) { h.Message(Succ, err) }

// Info 发送错误类型的值
func (h *MessageHandler) Info(err interface{}) {
h.Message(Info, err)
}
func (h *MessageHandler) Info(err interface{}) { h.Message(Info, err) }
4 changes: 3 additions & 1 deletion core/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package core

import (
"errors"
"io/fs"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -116,7 +118,7 @@ func (uri URI) Exists() (bool, error) {
switch scheme {
case SchemeFile, "":
_, err := os.Stat(path)
return (err == nil || os.IsExist(err)), nil
return err == nil || errors.Is(err, fs.ErrExist), nil
case SchemeHTTP, SchemeHTTPS:
return remoteFileIsExists(string(uri))
default:
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
module github.com/caixw/apidoc/v7

require (
github.com/issue9/assert/v2 v2.2.1
github.com/issue9/assert/v2 v2.3.2
github.com/issue9/cmdopt v0.7.2
github.com/issue9/errwrap v0.2.1
github.com/issue9/jsonrpc v0.12.1
github.com/issue9/localeutil v0.9.0
github.com/issue9/mux/v6 v6.0.0-beta.6
github.com/issue9/localeutil v0.12.0
github.com/issue9/mux/v6 v6.1.1
github.com/issue9/qheader v0.5.5
github.com/issue9/rands v1.2.0
github.com/issue9/sliceutil v0.8.0
github.com/issue9/sliceutil v0.10.1
github.com/issue9/source v0.1.2
github.com/issue9/term/v2 v2.1.5
github.com/issue9/validation v0.5.1
github.com/issue9/term/v3 v3.0.0
github.com/issue9/validation v0.6.1
github.com/issue9/version v1.0.5
golang.org/x/text v0.3.7
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0
)

require (
github.com/gorilla/websocket v1.4.2 // indirect
github.com/issue9/autoinc v1.0.8 // indirect
github.com/issue9/unique v1.3.1 // indirect
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab // indirect
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
)

go 1.18
31 changes: 16 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/issue9/assert/v2 v2.0.0/go.mod h1:rKr1eVGzXUhAo2af1thiKAhIA8uiSK9Wyn7mcZ4BzAg=
github.com/issue9/assert/v2 v2.2.1 h1:XQEnAFrGiT1Z55Tav39muM/Jg9ECiSLm7ehHQWoCHmA=
github.com/issue9/assert/v2 v2.2.1/go.mod h1:rKr1eVGzXUhAo2af1thiKAhIA8uiSK9Wyn7mcZ4BzAg=
github.com/issue9/assert/v2 v2.3.2 h1:J8TxGeak/CvrMchXHjs9CFChsZvpX0hGE/HTnwT6L+8=
github.com/issue9/assert/v2 v2.3.2/go.mod h1:rKr1eVGzXUhAo2af1thiKAhIA8uiSK9Wyn7mcZ4BzAg=
github.com/issue9/autoinc v1.0.8 h1:Vpi4ElzJOxyNKqw9wIsvNOSoh1xL9CNOp9vVQzouztI=
github.com/issue9/autoinc v1.0.8/go.mod h1:5LsFXszqd49znHXyPng+wFt6TYom5jCZoYNinFoKGgc=
github.com/issue9/cmdopt v0.7.2 h1:riBT70kOOU00rKmP4vseFI7hfDZBO0l00FosVcexWH8=
Expand All @@ -11,33 +12,33 @@ github.com/issue9/errwrap v0.2.1 h1:hrzBGbOCRs8acitpWSg54xNl2oaLGA/WZEf71bKaiEU=
github.com/issue9/errwrap v0.2.1/go.mod h1:hjjkt9S/owgy48er68ACFfA6YPDO/xax18QE3lsguVQ=
github.com/issue9/jsonrpc v0.12.1 h1:HApT4tU8icb1iRStCidMvQfZvKI4MHZYipsAkPNsDQU=
github.com/issue9/jsonrpc v0.12.1/go.mod h1:uRoxqflqgG/+R9B2Axwsc9OG85TwmdSlJSZwjULwVBc=
github.com/issue9/localeutil v0.9.0 h1:SeNzwzr/t1JfuVGt6xq6NXc/+RyWcLhT7etFIH3gUQc=
github.com/issue9/localeutil v0.9.0/go.mod h1:VDMtz5Y+YJopG+ibgDvrITYkGYC0WxrH20LOWIgTs9g=
github.com/issue9/mux/v6 v6.0.0-beta.6 h1:ZcIt/HEHzplZcYTTmmTMdj49DXrYOpj3Nb5/biFemp8=
github.com/issue9/mux/v6 v6.0.0-beta.6/go.mod h1:UX37BZvI3OEe20S2Jrw6LizgDnqO99NHqGXuVhzZ/7U=
github.com/issue9/localeutil v0.12.0 h1:1YaBHkEs4LwSA/HES+mwW+JAmAvAx209kNEMDRMJIno=
github.com/issue9/localeutil v0.12.0/go.mod h1:QkjGsEjoAqW66rwDZnTjjaUZUE4vQiD8OnxuPX3SbGY=
github.com/issue9/mux/v6 v6.1.1 h1:QV8pWb31nS3BmaOjv5w6GQv9PM5pusVM4ctKzxSsPj8=
github.com/issue9/mux/v6 v6.1.1/go.mod h1:ZYVzLEcesR+Hj/42c78lsFtUWKhSPXG+87j0x+Q9F74=
github.com/issue9/qheader v0.5.5 h1:6LxVoqnxIthEuoZn2rFBGxOdoxN9gh+n1GI1TiGQe4Q=
github.com/issue9/qheader v0.5.5/go.mod h1:oZVXJYWaO2ha6yFlYPrdkTpEpg8InAIRo65fGytoWRo=
github.com/issue9/rands v1.2.0 h1:gXxfhibkFTIhg9M57jsH9BcuCe7rpNMEpuTAzSGr7bk=
github.com/issue9/rands v1.2.0/go.mod h1:Bayx3LQFKasAHNTGVN3APtfeoNATAdNwWUN3b4X8Blw=
github.com/issue9/sliceutil v0.7.1/go.mod h1:8e+l2bD67pBUtV8cVnGChE/Ltlq8czcDLR1pOGCC2tE=
github.com/issue9/sliceutil v0.8.0 h1:a6I3vXPXMXkLw5Vhmz5+cD4kaiO+vWNBzZ/CUJ14slk=
github.com/issue9/sliceutil v0.8.0/go.mod h1:zzOSPwPHTsowvoCCx2RqCxQvPTKsxlb5eaPWWbSNAQ8=
github.com/issue9/sliceutil v0.10.1 h1:zoI2YWYSaAcp1uQUNSiApVVlOHF+wBjTOMrB8AnwIbE=
github.com/issue9/sliceutil v0.10.1/go.mod h1:zzOSPwPHTsowvoCCx2RqCxQvPTKsxlb5eaPWWbSNAQ8=
github.com/issue9/source v0.1.2 h1:Y70bsJOy9ks5MjY9O/3UnYsEu0a6lkzVm2AHQsqOl9c=
github.com/issue9/source v0.1.2/go.mod h1:HPkW33uwl4Kew44lERZ1jzV9Hr+a9Z32IaxgQPJKuPY=
github.com/issue9/term/v2 v2.1.5 h1:qU8C5Y7Zbv7amINkUirs/dtFxislNdW7QGHAuzssOX4=
github.com/issue9/term/v2 v2.1.5/go.mod h1:BA5+fQqPopRYlYfW3+NNmArSsHyPOmrsKksPh34DRdE=
github.com/issue9/term/v3 v3.0.0 h1:MJ0eavCCqZ9lv2souDyCkSDeVo3XM9auqFVE0s2Esos=
github.com/issue9/term/v3 v3.0.0/go.mod h1:D/UzioFydVy7DKLRit8ttJdGDkAa1Ni5fA9ZDWVD3lw=
github.com/issue9/unique v1.3.1 h1:OfM05QsuhKhLrHSUhwTFCBmQaqptwpUk1S5r6xZvaZU=
github.com/issue9/unique v1.3.1/go.mod h1:kXuutx4Mj60iR2/bCk4tAoXqxuO081rxIJjn+MucJRc=
github.com/issue9/validation v0.5.1 h1:olnraMrm4aKqkT60ILUVIJH3alZNLhEU/8NkCQJ7Ab4=
github.com/issue9/validation v0.5.1/go.mod h1:xi4eqjEdtwTXi4wepoyi68tvdYpSYzuU4JyVN9piFXA=
github.com/issue9/validation v0.6.1 h1:sbTiTgQ+RtWRepQTTiE52Ss8yqxBob3y6VG6Q9WYpJQ=
github.com/issue9/validation v0.6.1/go.mod h1:dFQbBVlr2dqd/7AippilmGK/tv/yT3aqtXVsRUIxPl4=
github.com/issue9/version v1.0.5 h1:y4JRHcAM0nXMBju9Vhe13Wv08KP/uNveP4uwg3Wknh8=
github.com/issue9/version v1.0.5/go.mod h1:bgni2RNBbtygajgpVeqBiEXT9JZjkLCuYJ4ceoSXjYo=
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab h1:rfJ1bsoJQQIAoAxTxB7bme+vHrNkRw8CqfsYh9w54cw=
golang.org/x/sys v0.0.0-20211123173158-ef496fb156ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 4 additions & 10 deletions internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"

"github.com/issue9/cmdopt"
"github.com/issue9/term/v2/colors"
"github.com/issue9/term/v3/colors"
"golang.org/x/text/message"

"github.com/caixw/apidoc/v7/core"
Expand Down Expand Up @@ -51,22 +51,16 @@ type printer struct {

type uri core.URI

func (u uri) Get() interface{} {
return string(u)
}
func (u uri) Get() interface{} { return string(u) }

func (u *uri) Set(v string) error {
*u = uri(core.FileURI(v))
return nil
}

func (u *uri) String() string {
return core.URI(*u).String()
}
func (u *uri) String() string { return core.URI(*u).String() }

func (u uri) URI() core.URI {
return core.URI(u)
}
func (u uri) URI() core.URI { return core.URI(u) }

// Init 初始化 cmdopt.CmdOpt 实例
func Init(out io.Writer) *cmdopt.CmdOpt {
Expand Down
13 changes: 3 additions & 10 deletions internal/lexer/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ func BlockEndPosition(b core.Block) (Position, error) {
return p, nil
}

// AtEOF 是否已经结束
func (l *Lexer) AtEOF() bool {
return l.Current().Offset > l.lastIndex
}
func (l *Lexer) AtEOF() bool { return l.Current().Offset > l.lastIndex }

// Match 接下来的 n 个字符是否匹配指定的字符串,
// 若匹配,则将指定移向该字符串这后,否则不作任何操作。
Expand All @@ -97,9 +94,7 @@ func (l *Lexer) Match(word string) bool {
}

// Current 返回当前在 data 中的偏移量
func (l *Lexer) Current() Position {
return l.current
}
func (l *Lexer) Current() Position { return l.current }

// Move 移动当前的分析器的位置
//
Expand Down Expand Up @@ -257,6 +252,4 @@ func (l *Lexer) Rollback() {
// Bytes 返回指定范围的内容
//
// NOTE: 并不会改变定位信息
func (l *Lexer) Bytes(start, end int) []byte {
return l.Data[start:end]
}
func (l *Lexer) Bytes(start, end int) []byte { return l.Data[start:end] }
12 changes: 3 additions & 9 deletions internal/lexer/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ type Position struct {
}

// Equal 判断与 v 是否相等
func (p Position) Equal(v Position) bool {
return p.Offset == v.Offset
}
func (p Position) Equal(v Position) bool { return p.Offset == v.Offset }

// AddRune 向后移动一个字符
func (p Position) AddRune(r rune) Position {
return p.add(r, utf8.RuneLen(r))
}
func (p Position) AddRune(r rune) Position { return p.add(r, utf8.RuneLen(r)) }

// SubRune 向前移动一个字符
func (p Position) SubRune(r rune) Position {
return p.sub(r, utf8.RuneLen(r))
}
func (p Position) SubRune(r rune) Position { return p.sub(r, utf8.RuneLen(r)) }

// 将 p 的定位回滚一个文字 r
//
Expand Down
4 changes: 1 addition & 3 deletions internal/locale/locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ func SetTag(tag language.Tag) {
}

// Tag 获取当前的本地化 ID
func Tag() language.Tag {
return localeTag
}
func Tag() language.Tag { return localeTag }

// Tags 所有支持语言的列表
func Tags() []language.Tag {
Expand Down
6 changes: 3 additions & 3 deletions internal/xmlenc/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
type (
// Decoder 实现从 p 中解码内容到当前对象的值
Decoder interface {
// 从 p 中读取内容并实例化到当前对象中
// DecodeXML 从 p 中读取内容并实例化到当前对象中
//
// 必须要同时从 p 中读取相应的 EndElement 才能返回。
// end 表示 EndElement.End 的值。
Expand All @@ -31,15 +31,15 @@ type (

// AttrDecoder 实现从 attr 中解码内容到当前对象的值
AttrDecoder interface {
// 解析属性值
// DecodeXMLAttr 解析属性值
//
// 接口应该只返回 *core.Error 作为错误对象。
DecodeXMLAttr(p *Parser, attr *Attribute) error
}

// Sanitizer 用于验证和修改对象中的数据
Sanitizer interface {
// 验证数据是否正确
// Sanitize 验证数据是否正确
//
// 可以通过 p.Error 等方法输出错误信息
Sanitize(p *Parser)
Expand Down
4 changes: 2 additions & 2 deletions internal/xmlenc/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (

// Encoder 将元素内容编码成 XML 内容
type Encoder interface {
// 仅需要返回元素内容的 XML 编码,不需要包含本身的标签和属性。
// EncodeXML 仅需要返回元素内容的 XML 编码,不需要包含本身的标签和属性。
EncodeXML() (string, error)
}

// AttrEncoder 将属性值编码成符合 XML 规范的值
type AttrEncoder interface {
// 仅需要返回属性的 XML 表示,不需要包含属性值的引号字符。
// EncodeXMLAttr 仅需要返回属性的 XML 表示,不需要包含属性值的引号字符。
EncodeXMLAttr() (string, error)
}

Expand Down

0 comments on commit 81230bd

Please sign in to comment.