inte:golangci-lint
This commit is contained in:
parent
14cf8b3dec
commit
4f0284c5a0
|
|
@ -0,0 +1,45 @@
|
|||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
permissions:
|
||||
contents: read
|
||||
# Optional: allow read access to pull request. Use with `only-new-issues` option.
|
||||
# pull-requests: read
|
||||
jobs:
|
||||
golangci:
|
||||
name: lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.17
|
||||
- uses: actions/checkout@v3
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
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: v1.29
|
||||
|
||||
# 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 all caching functionality will be complete disabled,
|
||||
# takes precedence over all other caching options.
|
||||
# skip-cache: 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
|
||||
|
|
@ -163,13 +163,11 @@ func bqlRawQuery(ledgerConfig *Config, selectBql string, queryParamsPtr *QueryPa
|
|||
bql = fmt.Sprintf("%s %s '%s' AND", bql, typeField.Tag.Get("bql"), val)
|
||||
}
|
||||
}
|
||||
break
|
||||
case reflect.Int:
|
||||
val := valueField.Int()
|
||||
if val != 0 {
|
||||
bql = fmt.Sprintf("%s %s %d AND", bql, typeField.Tag.Get("bql"), val)
|
||||
}
|
||||
break
|
||||
case reflect.Bool:
|
||||
val := valueField.Bool()
|
||||
// where 前的 from 可能会带有 and
|
||||
|
|
@ -179,7 +177,6 @@ func bqlRawQuery(ledgerConfig *Config, selectBql string, queryParamsPtr *QueryPa
|
|||
if val {
|
||||
bql = fmt.Sprintf("%s %s ", bql, typeField.Tag.Get("bql"))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
bql = strings.TrimRight(bql, " AND")
|
||||
|
|
@ -220,14 +217,12 @@ func parseResult(output string, queryResultPtr interface{}, selectOne bool) erro
|
|||
panic(err)
|
||||
}
|
||||
temp[jsonName] = i
|
||||
break
|
||||
// decimal
|
||||
case reflect.String, reflect.Struct:
|
||||
v := strings.Trim(val, " ")
|
||||
if v != "" {
|
||||
temp[jsonName] = v
|
||||
}
|
||||
break
|
||||
case reflect.Array, reflect.Slice:
|
||||
// 去除空格
|
||||
strArray := strings.Split(val, ",")
|
||||
|
|
@ -238,7 +233,6 @@ func parseResult(output string, queryResultPtr interface{}, selectOne bool) erro
|
|||
}
|
||||
}
|
||||
temp[jsonName] = notBlanks
|
||||
break
|
||||
default:
|
||||
panic("Unsupported field type")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ func GetAccountType(ledgerId string, acc string) AccountType {
|
|||
|
||||
func IsInWhiteList(ledgerId string) bool {
|
||||
// ledger white list is empty, return true
|
||||
if whiteList == nil || len(whiteList) == 0 {
|
||||
if len(whiteList) == 0 {
|
||||
return true
|
||||
}
|
||||
for i := range whiteList {
|
||||
|
|
|
|||
|
|
@ -269,13 +269,18 @@ func copyFile(sourceFilePath string, targetFilePath string, ledgerConfig script.
|
|||
newTargetFilePath := targetFilePath + "/" + fi.Name()
|
||||
if fi.IsDir() {
|
||||
err = script.MkDir(newTargetFilePath)
|
||||
if err == nil {
|
||||
err = copyFile(newSourceFilePath, newTargetFilePath, ledgerConfig)
|
||||
}
|
||||
} else if !script.FileIfExist(newTargetFilePath) {
|
||||
fileContent, err := script.ReadFile(newSourceFilePath)
|
||||
var fileContent, err = script.ReadFile(newSourceFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = script.WriteFile(newTargetFilePath, strings.ReplaceAll(strings.ReplaceAll(string(fileContent), "%startDate%", ledgerConfig.StartDate), "%operatingCurrency%", ledgerConfig.OperatingCurrency))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
script.LogInfo(ledgerConfig.Mail, "Success create file "+newTargetFilePath)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue