Fix go style issues

This commit is contained in:
Johannes M. Scheuermann 2022-01-31 08:19:12 +00:00 committed by Jingyu Zhou
parent 4bf14e6c47
commit 9985e0d350
14 changed files with 33 additions and 22 deletions

View File

@ -22,11 +22,12 @@ package main
import (
"bytes"
"strings"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"strings"
)
func (sm *StackMachine) popTuples(count int) []tuple.Tuple {

View File

@ -25,10 +25,11 @@ package directory
import (
"bytes"
"encoding/binary"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"math/rand"
"sync"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
)
var oneBytes = []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}

View File

@ -25,6 +25,7 @@ package directory
import (
"fmt"
"strings"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
)

View File

@ -24,6 +24,7 @@ package directory
import (
"bytes"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
)

View File

@ -78,8 +78,8 @@ type Subspace interface {
// FoundationDB keys (corresponding to the prefix of this Subspace).
fdb.KeyConvertible
// All Subspaces implement fdb.ExactRange and fdb.Range, and describe all
// keys strictly within the subspace that encode tuples. Specifically,
// All Subspaces implement fdb.ExactRange and fdb.Range, and describe all
// keys strictly within the subspace that encode tuples. Specifically,
// this will include all keys in [prefix + '\x00', prefix + '\xff').
fdb.ExactRange
}

View File

@ -102,7 +102,7 @@ func printTuple(tuple Tuple, sb *strings.Builder) {
fmt.Fprintf(sb, "%v", t)
}
if (i < len(tuple) - 1) {
if i < len(tuple)-1 {
sb.WriteString(", ")
}
}

View File

@ -121,7 +121,7 @@ func BenchmarkTuplePacking(b *testing.B) {
}
func TestTupleString(t *testing.T) {
testCases :=[ ]struct {
testCases := []struct {
input Tuple
expected string
}{

View File

@ -22,6 +22,7 @@ package main
import (
"fmt"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"

View File

@ -23,12 +23,13 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"io/ioutil"
"math/rand"
)
func clear_subspace(trtr fdb.Transactor, sub subspace.Subspace) error {
@ -69,7 +70,7 @@ func ToTuples(item interface{}) []tuple.Tuple {
switch i := item.(type) {
case []interface{}:
if len(i) == 0 {
return []tuple.Tuple{tuple.Tuple{EmptyList}}
return []tuple.Tuple{{EmptyList}}
}
tuples := make([]tuple.Tuple, 0)
for i, v := range i {
@ -80,7 +81,7 @@ func ToTuples(item interface{}) []tuple.Tuple {
return tuples
case map[string]interface{}:
if len(i) == 0 {
return []tuple.Tuple{tuple.Tuple{EmptyObject}}
return []tuple.Tuple{{EmptyObject}}
}
tuples := make([]tuple.Tuple, 0)
for k, v := range i {
@ -90,7 +91,7 @@ func ToTuples(item interface{}) []tuple.Tuple {
}
return tuples
default:
return []tuple.Tuple{tuple.Tuple{i}}
return []tuple.Tuple{{i}}
}
return nil
}
@ -119,7 +120,7 @@ func FromTuples(tuples []tuple.Tuple) interface{} {
if !ok {
group[k] = make([]tuple.Tuple, 0)
}
group[k] = append(group[k], t[0:len(t)])
group[k] = append(group[k], t[0:])
}
switch first[0].(type) {
@ -128,7 +129,7 @@ func FromTuples(tuples []tuple.Tuple) interface{} {
for _, g := range group {
subtup := make([]tuple.Tuple, 0)
for _, t := range g {
subtup = append(subtup, t[1:len(t)])
subtup = append(subtup, t[1:])
}
res = append(res, FromTuples(subtup))
}
@ -138,7 +139,7 @@ func FromTuples(tuples []tuple.Tuple) interface{} {
for _, g := range group {
subtup := make([]tuple.Tuple, 0)
for _, t := range g {
subtup = append(subtup, t[1:len(t)])
subtup = append(subtup, t[1:])
}
res[g[0][0].(string)] = FromTuples(subtup)
}
@ -210,7 +211,7 @@ func (doc Doc) GetDoc(trtr fdb.Transactor, doc_id int) interface{} {
if err != nil {
panic(err)
}
tuples = append(tuples, append(tup[1:len(tup)], _unpack(v.Value)...))
tuples = append(tuples, append(tup[1:], _unpack(v.Value)...))
}
return nil, nil
})

View File

@ -22,11 +22,12 @@ package main
import (
"fmt"
"log"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"log"
)
func clear_subspace(trtr fdb.Transactor, sub subspace.Subspace) error {

View File

@ -22,11 +22,12 @@ package main
import (
"fmt"
"log"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"log"
)
func clear_subspace(trtr fdb.Transactor, sub subspace.Subspace) error {

View File

@ -22,12 +22,13 @@ package main
import (
"fmt"
"log"
"math/rand"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"log"
"math/rand"
)
func clear_subspace(trtr fdb.Transactor, sub subspace.Subspace) error {

View File

@ -22,11 +22,12 @@ package main
import (
"fmt"
"log"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"log"
)
type EmptyQueueError struct{}

View File

@ -22,11 +22,12 @@ package main
import (
"fmt"
"log"
"github.com/apple/foundationdb/bindings/go/src/fdb"
"github.com/apple/foundationdb/bindings/go/src/fdb/directory"
"github.com/apple/foundationdb/bindings/go/src/fdb/subspace"
"github.com/apple/foundationdb/bindings/go/src/fdb/tuple"
"log"
)
func clear_subspace(trtr fdb.Transactor, sub subspace.Subspace) error {