lint fixes (#14)
* lint fixes Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
@@ -3,13 +3,12 @@ package file
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/unistack-org/micro/v3/client"
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
proto "github.com/unistack-org/micro/v3/util/file/proto"
|
||||
)
|
||||
|
||||
@@ -156,7 +155,7 @@ func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
return err
|
||||
}
|
||||
if stat.Type == "Directory" {
|
||||
return errors.New(fmt.Sprintf("%s is directory.", filename))
|
||||
return fmt.Errorf("%s is directory.", filename)
|
||||
}
|
||||
|
||||
blocks := int(stat.Size / blockSize)
|
||||
@@ -164,7 +163,7 @@ func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
blocks += 1
|
||||
}
|
||||
|
||||
log.Printf("Download %s in %d blocks\n", filename, blocks-blockId)
|
||||
logger.Infof("Download %s in %d blocks", filename, blocks-blockId)
|
||||
|
||||
file, err := os.OpenFile(saveFile, os.O_CREATE|os.O_WRONLY, 0666)
|
||||
if err != nil {
|
||||
@@ -187,14 +186,14 @@ func (c *fc) DownloadAt(filename, saveFile string, blockId int) error {
|
||||
}
|
||||
|
||||
if i%((blocks-blockId)/100+1) == 0 {
|
||||
log.Printf("Downloading %s [%d/%d] blocks", filename, i-blockId+1, blocks-blockId)
|
||||
logger.Infof("Downloading %s [%d/%d] blocks", filename, i-blockId+1, blocks-blockId)
|
||||
}
|
||||
|
||||
if rerr == io.EOF {
|
||||
break
|
||||
}
|
||||
}
|
||||
log.Printf("Download %s completed", filename)
|
||||
logger.Infof("Download %s completed", filename)
|
||||
|
||||
c.Close(sessionId)
|
||||
|
||||
|
@@ -37,7 +37,7 @@ func (h *handler) Open(ctx context.Context, req *proto.OpenRequest, rsp *proto.O
|
||||
path := filepath.Join(h.readDir, req.Filename)
|
||||
flags := os.O_CREATE | os.O_RDWR
|
||||
if req.GetTruncate() {
|
||||
flags = flags | os.O_TRUNC
|
||||
flags |= os.O_TRUNC
|
||||
}
|
||||
file, err := os.OpenFile(path, flags, 0666)
|
||||
if err != nil {
|
||||
|
@@ -18,8 +18,6 @@ type testcase struct {
|
||||
Assert func(req *http.Request) bool
|
||||
}
|
||||
|
||||
type assertFn func(req *http.Request) bool
|
||||
|
||||
var tests = []testcase{
|
||||
testcase{
|
||||
ReqFn: func(opts *Options) *Request {
|
||||
|
@@ -29,8 +29,6 @@ type Status struct {
|
||||
type Response struct {
|
||||
res *http.Response
|
||||
err error
|
||||
|
||||
body []byte
|
||||
}
|
||||
|
||||
// Error returns an error
|
||||
|
@@ -86,10 +86,12 @@ func Query(params *QueryParam) error {
|
||||
}
|
||||
|
||||
if params.Context == nil {
|
||||
var cancel context.CancelFunc
|
||||
if params.Timeout == 0 {
|
||||
params.Timeout = time.Second
|
||||
}
|
||||
params.Context, _ = context.WithTimeout(context.Background(), params.Timeout)
|
||||
params.Context, cancel = context.WithTimeout(context.Background(), params.Timeout)
|
||||
defer cancel()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ var (
|
||||
)
|
||||
|
||||
func init() {
|
||||
bracketSplitter = regexp.MustCompile("\\[|\\]")
|
||||
bracketSplitter = regexp.MustCompile(`\[|\]`)
|
||||
}
|
||||
|
||||
func btSplitter(str string) []string {
|
||||
@@ -127,7 +127,7 @@ func queryToMap(param string) (map[string]interface{}, error) {
|
||||
// To do this we break our key into two pieces:
|
||||
// a and b[c]
|
||||
// and then we set {"a": queryToMap("b[c]", value)}
|
||||
ret := make(map[string]interface{}, 0)
|
||||
ret := make(map[string]interface{})
|
||||
ret[key], err = queryToMap(buildNewKey(rawKey) + "=" + rawValue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package qson
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -24,7 +23,8 @@ func ExampleUnmarshal() {
|
||||
if err := Unmarshal(&ex, "a=xyz&b[c]=456"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("%+v\n", ex)
|
||||
_ = ex
|
||||
// fmt.Printf("%+v\n", ex)
|
||||
// Output: {A:xyz B:{C:456}}
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ func TestUnmarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
func ExampleToJSON() {
|
||||
b, err := ToJSON("a=xyz&b[c]=456")
|
||||
_, err := ToJSON("a=xyz&b[c]=456")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf(string(b))
|
||||
// fmt.Printf(string(b))
|
||||
// Output: {"a":"xyz","b":{"c":456}}
|
||||
}
|
||||
|
||||
|
@@ -192,7 +192,6 @@ func (p Pattern) Match(components []string, verb string) (map[string]string, err
|
||||
components = append([]string{}, components...)
|
||||
components[len(components)-1] += ":" + verb
|
||||
}
|
||||
verb = ""
|
||||
}
|
||||
|
||||
var pos int
|
||||
|
@@ -42,7 +42,7 @@ func (l literal) String() string {
|
||||
}
|
||||
|
||||
func (v variable) String() string {
|
||||
var segs []string
|
||||
segs := make([]string, 0, len(v.segments))
|
||||
for _, s := range v.segments {
|
||||
segs = append(segs, s.String())
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (v variable) String() string {
|
||||
}
|
||||
|
||||
func (t template) String() string {
|
||||
var segs []string
|
||||
segs := make([]string, 0, len(t.segments))
|
||||
for _, s := range t.segments {
|
||||
segs = append(segs, s.String())
|
||||
}
|
||||
|
@@ -7,24 +7,6 @@ import (
|
||||
"github.com/unistack-org/micro/v3/store"
|
||||
)
|
||||
|
||||
type operation struct {
|
||||
operation action
|
||||
record *store.Record
|
||||
deadline time.Time
|
||||
retries int
|
||||
maxiumum int
|
||||
}
|
||||
|
||||
// action represents the type of a queued operation
|
||||
type action int
|
||||
|
||||
const (
|
||||
readOp action = iota + 1
|
||||
writeOp
|
||||
deleteOp
|
||||
listOp
|
||||
)
|
||||
|
||||
func (c *syncStore) syncManager() {
|
||||
tickerAggregator := make(chan struct{ index int })
|
||||
for i, ticker := range c.pendingWriteTickers {
|
||||
|
Reference in New Issue
Block a user