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)
|
bql = fmt.Sprintf("%s %s '%s' AND", bql, typeField.Tag.Get("bql"), val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case reflect.Int:
|
case reflect.Int:
|
||||||
val := valueField.Int()
|
val := valueField.Int()
|
||||||
if val != 0 {
|
if val != 0 {
|
||||||
bql = fmt.Sprintf("%s %s %d AND", bql, typeField.Tag.Get("bql"), val)
|
bql = fmt.Sprintf("%s %s %d AND", bql, typeField.Tag.Get("bql"), val)
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case reflect.Bool:
|
case reflect.Bool:
|
||||||
val := valueField.Bool()
|
val := valueField.Bool()
|
||||||
// where 前的 from 可能会带有 and
|
// where 前的 from 可能会带有 and
|
||||||
|
|
@ -179,7 +177,6 @@ func bqlRawQuery(ledgerConfig *Config, selectBql string, queryParamsPtr *QueryPa
|
||||||
if val {
|
if val {
|
||||||
bql = fmt.Sprintf("%s %s ", bql, typeField.Tag.Get("bql"))
|
bql = fmt.Sprintf("%s %s ", bql, typeField.Tag.Get("bql"))
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bql = strings.TrimRight(bql, " AND")
|
bql = strings.TrimRight(bql, " AND")
|
||||||
|
|
@ -220,14 +217,12 @@ func parseResult(output string, queryResultPtr interface{}, selectOne bool) erro
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
temp[jsonName] = i
|
temp[jsonName] = i
|
||||||
break
|
|
||||||
// decimal
|
// decimal
|
||||||
case reflect.String, reflect.Struct:
|
case reflect.String, reflect.Struct:
|
||||||
v := strings.Trim(val, " ")
|
v := strings.Trim(val, " ")
|
||||||
if v != "" {
|
if v != "" {
|
||||||
temp[jsonName] = v
|
temp[jsonName] = v
|
||||||
}
|
}
|
||||||
break
|
|
||||||
case reflect.Array, reflect.Slice:
|
case reflect.Array, reflect.Slice:
|
||||||
// 去除空格
|
// 去除空格
|
||||||
strArray := strings.Split(val, ",")
|
strArray := strings.Split(val, ",")
|
||||||
|
|
@ -238,7 +233,6 @@ func parseResult(output string, queryResultPtr interface{}, selectOne bool) erro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
temp[jsonName] = notBlanks
|
temp[jsonName] = notBlanks
|
||||||
break
|
|
||||||
default:
|
default:
|
||||||
panic("Unsupported field type")
|
panic("Unsupported field type")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ func GetAccountType(ledgerId string, acc string) AccountType {
|
||||||
|
|
||||||
func IsInWhiteList(ledgerId string) bool {
|
func IsInWhiteList(ledgerId string) bool {
|
||||||
// ledger white list is empty, return true
|
// ledger white list is empty, return true
|
||||||
if whiteList == nil || len(whiteList) == 0 {
|
if len(whiteList) == 0 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
for i := range whiteList {
|
for i := range whiteList {
|
||||||
|
|
|
||||||
|
|
@ -269,13 +269,18 @@ func copyFile(sourceFilePath string, targetFilePath string, ledgerConfig script.
|
||||||
newTargetFilePath := targetFilePath + "/" + fi.Name()
|
newTargetFilePath := targetFilePath + "/" + fi.Name()
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
err = script.MkDir(newTargetFilePath)
|
err = script.MkDir(newTargetFilePath)
|
||||||
|
if err == nil {
|
||||||
err = copyFile(newSourceFilePath, newTargetFilePath, ledgerConfig)
|
err = copyFile(newSourceFilePath, newTargetFilePath, ledgerConfig)
|
||||||
|
}
|
||||||
} else if !script.FileIfExist(newTargetFilePath) {
|
} else if !script.FileIfExist(newTargetFilePath) {
|
||||||
fileContent, err := script.ReadFile(newSourceFilePath)
|
var fileContent, err = script.ReadFile(newSourceFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = script.WriteFile(newTargetFilePath, strings.ReplaceAll(strings.ReplaceAll(string(fileContent), "%startDate%", ledgerConfig.StartDate), "%operatingCurrency%", ledgerConfig.OperatingCurrency))
|
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)
|
script.LogInfo(ledgerConfig.Mail, "Success create file "+newTargetFilePath)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue