Skip to content

Commit d31b191

Browse files
committed
Fix lints.
1 parent 3dc8f82 commit d31b191

File tree

15 files changed

+66
-86
lines changed

15 files changed

+66
-86
lines changed

actor.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import (
55
"time"
66
)
77

8-
var (
9-
ErrActorAskTimeout = fmt.Errorf("ErrActorAskTimeout")
10-
)
8+
var ErrActorAskTimeout = fmt.Errorf("ErrActorAskTimeout")
119

1210
// ActorHandle A target could send messages
1311
type ActorHandle interface {
@@ -183,9 +181,9 @@ func (askSelf *AskDef) Reply(response interface{}) {
183181
var Ask AskDef
184182

185183
func init() {
186-
//Ask = *Ask.New(0, nil)
187-
//Actor = *Actor.New(func(_ *ActorDef, _ interface{}) {})
188-
//Actor.Close()
184+
// Ask = *Ask.New(0, nil)
185+
// Actor = *Actor.New(func(_ *ActorDef, _ interface{}) {})
186+
// Actor.Close()
189187
Actor.isClosed = true
190188
defaultActor = &Actor
191189
}

actor_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,23 @@ func TestActorAsk(t *testing.T) {
112112
timeout = 10 * time.Millisecond
113113

114114
// Normal cases
115-
actual = 0
116115
expectedInt = 10
117116
result, _ = Ask.New(1).AskOnce(actorRoot, nil)
118117
actual, _ = Maybe.Just(result).ToInt()
119118
assert.Equal(t, expectedInt, actual)
120119
// Ask with Timeout
121-
actual = 0
122120
expectedInt = 20
123121
result, _ = Ask.New(2).AskOnce(actorRoot, &timeout)
124122
actual, _ = Maybe.Just(result).ToInt()
125123
assert.Equal(t, expectedInt, actual)
126124
// Ask channel
127-
actual = 0
128125
expectedInt = 30
129126
ch := AskNewGenerics(3).AskChannel(actorRoot)
130127
actual, _ = Maybe.Just(<-*ch).ToInt()
131128
close(*ch)
132129
assert.Equal(t, expectedInt, actual)
133130

134131
// Timeout cases
135-
actual = 9999
136132
expectedInt = 0
137133
result, err = Ask.New(-1).AskOnce(actorRoot, &timeout)
138134
actual, _ = Maybe.Just(result).ToInt()

cor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (corSelf *CorDef) YieldFrom(target *CorDef, in interface{}) interface{} {
143143

144144
return result
145145
}
146+
146147
func (corSelf *CorDef) receive(cor *CorDef, in interface{}) {
147148
corSelf.doCloseSafe(func() {
148149
if corSelf.opCh != nil {
@@ -179,6 +180,7 @@ func (corSelf *CorDef) IsDone() bool {
179180
func (corSelf *CorDef) IsStarted() bool {
180181
return corSelf.isStarted.Get()
181182
}
183+
182184
func (corSelf *CorDef) close() {
183185
corSelf.isClosed.Set(true)
184186

@@ -191,6 +193,7 @@ func (corSelf *CorDef) close() {
191193
}
192194
corSelf.closedM.Unlock()
193195
}
196+
194197
func (corSelf *CorDef) doCloseSafe(fn func()) {
195198
if corSelf.IsDone() {
196199
return

cor_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func logMessage(args ...interface{}) {
1616
}
1717

1818
func TestCorYield(t *testing.T) {
19-
var expectedInt int
20-
var actualInt = 0
19+
var expectedInt, actualInt int
2120
var testee *CorDef
2221
var wg sync.WaitGroup
2322

fp.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func Compose(fnList ...func(...interface{}) []interface{}) func(...interface{})
6565
// Pipe Pipe the functions from left to right
6666
func Pipe(fnList ...func(...interface{}) []interface{}) func(...interface{}) []interface{} {
6767
return func(s ...interface{}) []interface{} {
68-
6968
lastIndex := len(fnList) - 1
7069
f := fnList[lastIndex]
7170
nextFnList := fnList[:lastIndex]
@@ -100,7 +99,6 @@ func MapIndexed(fn func(interface{}, int) interface{}, values ...interface{}) []
10099

101100
// Reduce Reduce the values from left to right(func(memo,val), starting value, slice)
102101
func Reduce(fn ReducerFunctor, memo interface{}, input ...interface{}) interface{} {
103-
104102
for i := 0; i < len(input); i++ {
105103
memo = fn(memo, input[i])
106104
}
@@ -110,7 +108,6 @@ func Reduce(fn ReducerFunctor, memo interface{}, input ...interface{}) interface
110108

111109
// ReduceIndexed Reduce the values from left to right(func(memo,val,index), starting value, slice)
112110
func ReduceIndexed(fn func(interface{}, interface{}, int) interface{}, memo interface{}, input ...interface{}) interface{} {
113-
114111
for i := 0; i < len(input); i++ {
115112
memo = fn(memo, input[i], i)
116113
}
@@ -120,9 +117,9 @@ func ReduceIndexed(fn func(interface{}, interface{}, int) interface{}, memo inte
120117

121118
// Filter Filter the values by the given predicate function (predicate func, slice)
122119
func Filter(fn func(interface{}, int) bool, input ...interface{}) []interface{} {
123-
var list = make([]interface{}, len(input))
120+
list := make([]interface{}, len(input))
124121

125-
var newLen = 0
122+
newLen := 0
126123

127124
for i := range input {
128125
if fn(input[i], i) {
@@ -145,18 +142,18 @@ func Reject(fn func(interface{}, int) bool, input ...interface{}) []interface{}
145142

146143
// Concat Concat slices
147144
func Concat(mine []interface{}, slices ...[]interface{}) []interface{} {
148-
var mineLen = len(mine)
149-
var totalLen = mineLen
145+
mineLen := len(mine)
146+
totalLen := mineLen
150147

151148
for _, slice := range slices {
152149
if slice == nil {
153150
continue
154151
}
155152

156-
var targetLen = len(slice)
153+
targetLen := len(slice)
157154
totalLen += targetLen
158155
}
159-
var newOne = make([]interface{}, totalLen)
156+
newOne := make([]interface{}, totalLen)
160157

161158
for i, item := range mine {
162159
newOne[i] = item
@@ -168,8 +165,8 @@ func Concat(mine []interface{}, slices ...[]interface{}) []interface{} {
168165
continue
169166
}
170167

171-
var target = slice
172-
var targetLen = len(target)
168+
target := slice
169+
targetLen := len(target)
173170
for j, item := range target {
174171
newOne[totalIndex+j] = item
175172
}
@@ -646,7 +643,7 @@ func PMap(f TransformerFunctor, option *PMapOption, list ...interface{}) []inter
646643
return make([]interface{}, 0)
647644
}
648645

649-
var worker = len(list)
646+
worker := len(list)
650647
if option != nil {
651648
if option.FixedPool > 0 && option.FixedPool < worker {
652649
worker = option.FixedPool
@@ -942,7 +939,6 @@ func UniqBy(identify TransformerFunctor, list ...interface{}) []interface{} {
942939

943940
// Flatten creates a new slice where one level of nested elements are unnested
944941
func Flatten(list ...[]interface{}) []interface{} {
945-
946942
result := make([]interface{}, 0)
947943

948944
// for _, v := range list {
@@ -952,7 +948,7 @@ func Flatten(list ...[]interface{}) []interface{} {
952948
return Concat(result, list...)
953949
}
954950

955-
// Prepend returns the slice with the additional element added to the beggining
951+
// Prepend returns the slice with the additional element added to the beginning
956952
func Prepend(element interface{}, list []interface{}) []interface{} {
957953
return append([]interface{}{element}, list...)
958954
}
@@ -1500,8 +1496,7 @@ type ProductType struct {
15001496
}
15011497

15021498
// NilTypeDef NilType implemented by Nil determinations
1503-
type NilTypeDef struct {
1504-
}
1499+
type NilTypeDef struct{}
15051500

15061501
// Matches Check does it match the SumType
15071502
func (typeSelf SumType) Matches(value ...interface{}) bool {

fp_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ func SortStringAscending(input ...interface{}) []interface{} {
3232
func TestCompose(t *testing.T) {
3333
var expectedinteger int
3434

35-
var fn01 = func(args ...interface{}) []interface{} {
35+
fn01 := func(args ...interface{}) []interface{} {
3636
val, _ := Maybe.Just(args[0]).ToInt()
3737
return SliceOf(val + 1)
3838
}
39-
var fn02 = func(args ...interface{}) []interface{} {
39+
fn02 := func(args ...interface{}) []interface{} {
4040
val, _ := Maybe.Just(args[0]).ToInt()
4141
return SliceOf(val + 2)
4242
}
43-
var fn03 = func(args ...interface{}) []interface{} {
43+
fn03 := func(args ...interface{}) []interface{} {
4444
val, _ := Maybe.Just(args[0]).ToInt()
4545
return SliceOf(val + 3)
4646
}
@@ -68,7 +68,6 @@ func TestCompose(t *testing.T) {
6868

6969
expectedinteger = 6
7070
assert.Equal(t, expectedinteger, Pipe(fn01, fn02, fn03)((0))[0])
71-
7271
}
7372

7473
func TestFPFunctions(t *testing.T) {
@@ -98,7 +97,6 @@ func TestFPFunctions(t *testing.T) {
9897
var actualMap map[interface{}]interface{}
9998

10099
fib := func(n int) int {
101-
102100
result, _ := Trampoline(func(input ...interface{}) ([]interface{}, bool, error) {
103101
n, _ := Maybe.Just(input[0]).ToInt()
104102
a, _ := Maybe.Just(input[1]).ToInt()
@@ -237,7 +235,6 @@ func TestFPFunctions(t *testing.T) {
237235
aVal, _ := Maybe.Just(a).ToInt()
238236
return aVal % 2
239237
}, 1, 2, 3, 4, 5, 6, 7, 8))
240-
241238
}
242239

243240
func TestVariadic(t *testing.T) {
@@ -326,9 +323,9 @@ func TestCurry(t *testing.T) {
326323
}
327324

328325
func TestCompType(t *testing.T) {
329-
var compTypeA = DefProduct(reflect.Int, reflect.String)
330-
var compTypeB = DefProduct(reflect.String)
331-
var myType = DefSum(NilType, compTypeA, compTypeB)
326+
compTypeA := DefProduct(reflect.Int, reflect.String)
327+
compTypeB := DefProduct(reflect.String)
328+
myType := DefSum(NilType, compTypeA, compTypeB)
332329

333330
assert.Equal(t, true, myType.Matches((1), ("1")))
334331
assert.Equal(t, true, myType.Matches(("2")))
@@ -341,9 +338,9 @@ func TestCompType(t *testing.T) {
341338
}
342339

343340
func TestPatternMatching(t *testing.T) {
344-
var compTypeA = DefProduct(reflect.Int, reflect.String)
345-
var compTypeB = DefProduct(reflect.String, reflect.String)
346-
var myType = DefSum(NilType, compTypeA, compTypeB)
341+
compTypeA := DefProduct(reflect.Int, reflect.String)
342+
compTypeB := DefProduct(reflect.String, reflect.String)
343+
myType := DefSum(NilType, compTypeA, compTypeB)
347344

348345
assert.Equal(t, true, compTypeA.Matches(1, "3"))
349346
assert.Equal(t, false, compTypeA.Matches(1, 3))
@@ -352,7 +349,7 @@ func TestPatternMatching(t *testing.T) {
352349
assert.Equal(t, true, myType.Matches("1", "3"))
353350
assert.Equal(t, false, myType.Matches(1, 3))
354351

355-
var patterns = []Pattern{
352+
patterns := []Pattern{
356353
InCaseOfKind(reflect.Int, func(x interface{}) interface{} {
357354
return (fmt.Sprintf("Integer: %v", x))
358355
}),
@@ -369,7 +366,7 @@ func TestPatternMatching(t *testing.T) {
369366
return (fmt.Sprintf("got this object: %v", x))
370367
}),
371368
}
372-
var pm = DefPattern(patterns...)
369+
pm := DefPattern(patterns...)
373370
assert.Equal(t, "Integer: 42", pm.MatchFor((42)))
374371
assert.Equal(t, "Hello world", pm.MatchFor(("world")))
375372
assert.Equal(t, "Matched: ccc", pm.MatchFor(("ccc")))

maybe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (maybeSelf someDef) ToPtr() *interface{} {
126126

127127
// ToMaybe Maybe to Maybe
128128
func (maybeSelf someDef) ToMaybe() MaybeDef {
129-
var ref = maybeSelf.ref
129+
ref := maybeSelf.ref
130130
switch (ref).(type) {
131131
default:
132132
return maybeSelf

maybe_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestIsPresent(t *testing.T) {
1919
assert.Equal(t, false, m.IsPresent())
2020
assert.Equal(t, true, m.IsNil())
2121

22-
var i = 1
22+
i := 1
2323
var iptr *int
2424

2525
iptr = nil
@@ -45,9 +45,9 @@ func TestOr(t *testing.T) {
4545
func TestClone(t *testing.T) {
4646
var m MaybeDef
4747

48-
var i = 1
49-
var i2 = 2
50-
var temp = 3
48+
i := 1
49+
i2 := 2
50+
temp := 3
5151
var iptr *int
5252
var iptr2 *int
5353
iptr2 = &i2

monadIO.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ func (monadIOSelf *MonadIODef) New(effect func() interface{}) *MonadIODef {
2727

2828
// FlatMap FlatMap the MonadIO by function
2929
func (monadIOSelf *MonadIODef) FlatMap(fn func(interface{}) *MonadIODef) *MonadIODef {
30-
3130
return &MonadIODef{effect: func() interface{} {
3231
next := fn(monadIOSelf.doEffect())
3332
return next.doEffect()
3433
}}
35-
3634
}
3735

3836
// Subscribe Subscribe the MonadIO by Subscription
@@ -53,8 +51,8 @@ func (monadIOSelf *MonadIODef) ObserveOn(h *HandlerDef) *MonadIODef {
5351
monadIOSelf.obOn = h
5452
return monadIOSelf
5553
}
56-
func (monadIOSelf *MonadIODef) doSubscribe(s *Subscription, obOn *HandlerDef, subOn *HandlerDef) *Subscription {
5754

55+
func (monadIOSelf *MonadIODef) doSubscribe(s *Subscription, obOn *HandlerDef, subOn *HandlerDef) *Subscription {
5856
if s.OnNext != nil {
5957
var result interface{}
6058

@@ -79,6 +77,7 @@ func (monadIOSelf *MonadIODef) doSubscribe(s *Subscription, obOn *HandlerDef, su
7977

8078
return s
8179
}
80+
8281
func (monadIOSelf *MonadIODef) doEffect() interface{} {
8382
return monadIOSelf.effect()
8483
}

network/simpleHTTP.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ func (simpleHTTPSelf *SimpleHTTPDef) DoNewRequestWithBodyOptions(context context
224224

225225
// DoRequest Do HTTP Request with interceptors
226226
func (simpleHTTPSelf *SimpleHTTPDef) DoRequest(request *http.Request) *ResponseWithError {
227-
228227
response, err := simpleHTTPSelf.client.Do(request)
229228

230229
return &ResponseWithError{
@@ -454,7 +453,6 @@ func (simpleAPISelf *SimpleAPIDef) MakeDoNewRequestWithMultipartSerializer(metho
454453
func (simpleAPISelf *SimpleAPIDef) MakeDoNewRequest(method string, relativeURL string) APINoBody {
455454
return APINoBody(func(pathParam PathParam, target interface{}) *fpgo.MonadIODef {
456455
return fpgo.MonadIO.New(func() interface{} {
457-
458456
ctx, cancel := simpleAPISelf.GetSimpleHTTP().GetContextTimeout()
459457
defer cancel()
460458
response := simpleAPISelf.simpleHTTP.DoNewRequest(ctx, simpleAPISelf.DefaultHeader.Clone(), method, simpleAPISelf.replacePathParams(relativeURL, pathParam))

0 commit comments

Comments
 (0)