Skip to content

Commit

Permalink
Add: github action
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks committed Dec 13, 2020
1 parent 4e3d8d4 commit d5cb050
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
chmod u+x /tmp/tools/license/license-header-checker
/tmp/tools/license/license-header-checker -v -a -r -i vendor /tmp/tools/license/license.txt . go && [[ -z `git status -s` ]]
- name: Install go ci lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0

- name: Run Linter
run: golangci-lint run --timeout=10m -v --disable-all --enable=govet --enable=staticcheck --enable=ineffassign --enable=misspell

- name: Go Test
run: GO111MODULE=on && go mod vendor && go test ./... -bench . -race -v -coverprofile=coverage.txt

Expand Down
12 changes: 6 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ linters-settings:
disabled-checks:
- wrapperFunc

linters:
enable-all: true
disable:
- maligned
- prealloc
- gochecknoglobals
# linters:
# enable-all: true
# disable:
# - maligned
# - prealloc
# - gochecknoglobals

run:
skip-dirs:
Expand Down
4 changes: 3 additions & 1 deletion context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import (
"context"
)

type ValueContextKeyType int32

var (
defaultCtxKey = 1
defaultCtxKey = ValueContextKeyType(1)
)

type Values struct {
Expand Down
3 changes: 2 additions & 1 deletion context/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package gxcontext

import (
"context"
"testing"
)

Expand All @@ -26,7 +27,7 @@ import (
)

func TestValuesContext_General(t *testing.T) {
vc := NewValuesContext(nil)
vc := NewValuesContext(context.Background())
assert.NotNil(t, vc)

key := "hello"
Expand Down
10 changes: 5 additions & 5 deletions log/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ func funcFileLine() string {

func CPrintf(color []byte, format string, args ...interface{}) {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprintf(os.Stdout, string(color)+funcFileLine()+fmt.Sprintf(format, args...)+string(reset))
fmt.Fprint(os.Stdout, string(color)+funcFileLine()+fmt.Sprintf(format, args...)+string(reset))
} else {
fmt.Fprintf(os.Stdout, fmt.Sprintf(format, args...))
fmt.Fprint(os.Stdout, fmt.Sprintf(format, args...))
}
}

func CPrintfln(color []byte, format string, args ...interface{}) {
logStr := fmt.Sprintf(format, args...)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprintf(os.Stdout, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
fmt.Fprint(os.Stdout, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
} else {
fmt.Fprintf(os.Stdout, "%s\n", logStr)
}
Expand All @@ -85,7 +85,7 @@ func CPrintfln(color []byte, format string, args ...interface{}) {
func CEPrintf(color []byte, format string, args ...interface{}) {
logStr := fmt.Sprintf(format, args...)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprintf(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset), logStr)
fmt.Fprint(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset), logStr)
} else {
fmt.Fprintf(os.Stderr, "%s", logStr)
}
Expand All @@ -94,7 +94,7 @@ func CEPrintf(color []byte, format string, args ...interface{}) {
func CEPrintfln(color []byte, format string, args ...interface{}) {
logStr := fmt.Sprintf(format, args...)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Fprintf(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
fmt.Fprint(os.Stderr, string(color)+funcFileLine()+"%s"+string(reset)+"\n", logStr)
} else {
fmt.Fprintf(os.Stderr, "%s\n", logStr)
}
Expand Down
22 changes: 13 additions & 9 deletions math/big/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ const (
DivFracIncr = 4

// ModeHalfEven rounds normally.
ModeHalfEven RoundMode = 5
ModeHalfEven = RoundMode(5)
// Truncate just truncates the decimal.
ModeTruncate RoundMode = 10
ModeTruncate = RoundMode(10)
// Ceiling is not supported now.
modeCeiling RoundMode = 0
maxDecimalScale = 30
modeCeiling = RoundMode(0)
maxDecimalScale = int32(30)
)

var (
Expand Down Expand Up @@ -1173,7 +1173,7 @@ with the correct -1/0/+1 result
7E F2 04 C7 2D FB 2D
*/
func (d *Decimal) ToBin(precision, frac int) ([]byte, error) {
if precision > digitsPerWord*maxWordBufLen || precision < 0 || frac > maxDecimalScale || frac < 0 {
if precision > digitsPerWord*maxWordBufLen || precision < 0 || frac > int(maxDecimalScale) || frac < 0 {
return nil, ErrBadNumber
}
var err error
Expand Down Expand Up @@ -1773,10 +1773,12 @@ func doAdd(from1, from2, to *Decimal) error {
stop = 0
if wordsInt1 > wordsInt2 {
idx1 = wordsInt1 - wordsInt2
dec1, dec2 = from1, from2
// dec1, dec2 = from1, from2
dec1 = from1
} else {
idx1 = wordsInt2 - wordsInt1
dec1, dec2 = from2, from1
// dec1, dec2 = from2, from1
dec1 = from2
}
for idx1 > stop {
idxTo--
Expand Down Expand Up @@ -1853,7 +1855,8 @@ func DecimalMul(from1, from2, to *Decimal) error {
tmp1 = wordsIntTo
tmp2 = wordsFracTo
)
to.resultFrac = myMinInt8(from1.resultFrac+from2.resultFrac, maxDecimalScale)
// to.resultFrac = myMinInt8(from1.resultFrac+from2.resultFrac, maxDecimalScale)
to.resultFrac = myMinInt8(from1.resultFrac+from2.resultFrac, int8(30))
wordsIntTo, wordsFracTo, err = fixWordCntError(wordsIntTo, wordsFracTo)
to.negative = from1.negative != from2.negative
to.digitsFrac = from1.digitsFrac + from2.digitsFrac
Expand Down Expand Up @@ -1967,7 +1970,8 @@ func DecimalMul(from1, from2, to *Decimal) error {
// to - quotient
// fracIncr - increment of fraction
func DecimalDiv(from1, from2, to *Decimal, fracIncr int) error {
to.resultFrac = myMinInt8(from1.resultFrac+int8(fracIncr), maxDecimalScale)
// to.resultFrac = myMinInt8(from1.resultFrac+int8(fracIncr), int8(maxDecimalScale))
to.resultFrac = myMinInt8(from1.resultFrac+int8(fracIncr), int8(30))
return doDivMod(from1, from2, to, nil, fracIncr)
}

Expand Down
2 changes: 1 addition & 1 deletion math/big/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestShift(t *testing.T) {
for _, ca := range tests {
var dec Decimal
err := dec.FromBytes([]byte(ca.input))
//assert.Equal(t, err, IsNil)
assert.Nil(t, err)
//origin := dec
err = dec.Shift(ca.shift)
assert.Equal(t, err, ca.err)
Expand Down
3 changes: 3 additions & 0 deletions runtime/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func GetProcessMemoryStat() (uint64, error) {
}

memInfo, err := p.MemoryInfo()
if err != nil {
return 0, err
}

return memInfo.RSS, nil
}
Expand Down

0 comments on commit d5cb050

Please sign in to comment.