Skip to content

Commit

Permalink
Merge pull request #474 from ncopa/fix-go-vet-errors
Browse files Browse the repository at this point in the history
Fix go vet errors (#473)
  • Loading branch information
adubovikov authored Jun 7, 2021
2 parents 1071aa4 + e58baf4 commit 524c02b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ func WriteJSONString(w io.Writer, s string) (int, error) {

func stb(s string) []byte {
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
bh := reflect.SliceHeader{
Data: sh.Data,
Len: sh.Len,
Cap: sh.Len,
}
return *(*[]byte)(unsafe.Pointer(&bh))
var res []byte

bh := (*reflect.SliceHeader)((unsafe.Pointer(&res)))
bh.Data = sh.Data
bh.Len = sh.Len
bh.Cap = sh.Len
return res
}

func toUTF8(s, replacement string) string {
Expand Down
9 changes: 5 additions & 4 deletions rotator/rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ func (r *Rotator) getSizeInBtyes() (float64, error) {

func (r *Rotator) GetDatabaseSize(db *sql.DB, schema string) (float64, error) {
var databaseSize string
var size float64
var err error
switch schema {
case "maxusage":
rows, err := db.Query("select pg_database_size('homer_data');")
Expand All @@ -205,7 +207,7 @@ func (r *Rotator) GetDatabaseSize(db *sql.DB, schema string) (float64, error) {
return 0, err
}
}
return strconv.ParseFloat(databaseSize, 64)
size, err = strconv.ParseFloat(databaseSize, 64)
default:
rows, err := db.Query("select * from sys_df();")
checkDBErr(err)
Expand All @@ -216,10 +218,9 @@ func (r *Rotator) GetDatabaseSize(db *sql.DB, schema string) (float64, error) {
return 0, err
}
}
percentageUsage, _ := strconv.ParseFloat(strings.TrimSuffix(strings.Split(databaseSize[1:len(databaseSize)-1], ",")[4], "%"), 64)
return percentageUsage, nil
size, err = strconv.ParseFloat(strings.TrimSuffix(strings.Split(databaseSize[1:len(databaseSize)-1], ",")[4], "%"), 64)
}
return 0, nil
return size, err
}

func (r *Rotator) UsageProtection(scheme string) error {
Expand Down

0 comments on commit 524c02b

Please sign in to comment.