1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-12 19:58:36 +08:00
This commit is contained in:
源文雨
2023-02-23 13:20:31 +08:00
parent 8f87a17722
commit 59cce024f7
5 changed files with 150 additions and 1 deletions

35
.github/workflows/pull.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: PullLint
on: [ pull_request ]
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@master
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true

33
.github/workflows/push.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: PushLint
on: [ push ]
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.19
- name: Check out code into the Go module directory
uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@master
with:
version: latest
- name: Commit back
if: ${{ !github.head_ref }}
continue-on-error: true
run: |
git config --local user.name 'github-actions[bot]'
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add --all
git commit -m "🎨 改进代码样式"
- name: Create Pull Request
if: ${{ !github.head_ref }}
continue-on-error: true
uses: peter-evans/create-pull-request@v4

76
.golangci.yml Normal file
View File

@@ -0,0 +1,76 @@
linters-settings:
errcheck:
ignore: fmt:.*
ignoretests: true
goimports:
local-prefixes: github.com/fumiama/docxlib
forbidigo:
# Forbid the following identifiers
forbid:
- ^fmt\.Errorf$ # consider errors.Errorf in github.com/pkg/errors
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
fast: false
enable:
- bodyclose
- depguard
- dogsled
- errcheck
- exportloopref
- exhaustive
#- funlen
#- goconst
- gocritic
#- gocyclo
- gofmt
- goimports
- goprintffuncname
#- gosec
- gosimple
- govet
- ineffassign
#- misspell
- nolintlint
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
- prealloc
- predeclared
- asciicheck
- revive
- forbidigo
- makezero
run:
# default concurrency is a available CPU number.
# concurrency: 4 # explicitly omit this value to fully utilize available resources.
deadline: 5m
issues-exit-code: 1
tests: false
skip-dirs:
- order
go: '1.19'
# output configuration options
output:
format: "colored-line-number"
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
issues:
# Fix found issues (if it's supported by the linter)
fix: true
exclude-use-default: false
exclude:
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Seek|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check"

View File

@@ -82,7 +82,7 @@ func (p *Paragraph) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
} }
} }
for _, c := range p.Children { for _, c := range p.Children {
e.Encode(c) err = e.Encode(c)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -71,6 +71,11 @@ func (r *Run) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
} }
// WTab is the literal tab
type WTab struct {
XMLName xml.Name `xml:"w:tab,omitempty"`
}
// RunProperties encapsulates visual properties of a run // RunProperties encapsulates visual properties of a run
type RunProperties struct { type RunProperties struct {
XMLName xml.Name `xml:"w:rPr,omitempty"` XMLName xml.Name `xml:"w:rPr,omitempty"`