Skip to content

Commit 0b406e4

Browse files
committed
Format by gofmt/gofumpt (gofumpt -l -w .)
1 parent 456039a commit 0b406e4

19 files changed

+80
-95
lines changed

actor.go

Lines changed: 1 addition & 3 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[T any] interface {

cor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func (corSelf *CorDef[T]) YieldFrom(target *CorDef[T], in T) T {
148148

149149
return result
150150
}
151+
151152
func (corSelf *CorDef[T]) receive(cor *CorDef[T], in T) {
152153
corSelf.doCloseSafe(func() {
153154
if corSelf.opCh != nil {
@@ -184,6 +185,7 @@ func (corSelf *CorDef[T]) IsDone() bool {
184185
func (corSelf *CorDef[T]) IsStarted() bool {
185186
return corSelf.isStarted.Get()
186187
}
188+
187189
func (corSelf *CorDef[T]) close() {
188190
corSelf.isClosed.Set(true)
189191

@@ -196,6 +198,7 @@ func (corSelf *CorDef[T]) close() {
196198
}
197199
corSelf.closedM.Unlock()
198200
}
201+
199202
func (corSelf *CorDef[T]) doCloseSafe(fn func()) {
200203
if corSelf.IsDone() {
201204
return

cor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func logMessage(args ...interface{}) {
1717

1818
func TestCorYield(t *testing.T) {
1919
var expectedInt int
20-
var actualInt = 0
20+
actualInt := 0
2121
var testee *CorDef[interface{}]
2222
var wg sync.WaitGroup
2323

fp.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ func ComposeInterface(fnList ...func(...interface{}) []interface{}) func(...inte
9191
// Pipe Pipe the functions from left to right
9292
func Pipe[T any](fnList ...func(...T) []T) func(...T) []T {
9393
return func(s ...T) []T {
94-
9594
lastIndex := len(fnList) - 1
9695
f := fnList[lastIndex]
9796
nextFnList := fnList[:lastIndex]
@@ -131,7 +130,6 @@ func MapIndexed[T any, R any](fn func(T, int) R, values ...T) []R {
131130

132131
// Reduce Reduce the values from left to right(func(memo,val), starting value, slice)
133132
func Reduce[T any, R any](fn ReducerFunctor[T, R], memo R, input ...T) R {
134-
135133
for i := 0; i < len(input); i++ {
136134
memo = fn(memo, input[i])
137135
}
@@ -141,7 +139,6 @@ func Reduce[T any, R any](fn ReducerFunctor[T, R], memo R, input ...T) R {
141139

142140
// ReduceIndexed Reduce the values from left to right(func(memo,val,index), starting value, slice)
143141
func ReduceIndexed[T any, R any](fn func(R, T, int) R, memo R, input ...T) R {
144-
145142
for i := 0; i < len(input); i++ {
146143
memo = fn(memo, input[i], i)
147144
}
@@ -151,9 +148,9 @@ func ReduceIndexed[T any, R any](fn func(R, T, int) R, memo R, input ...T) R {
151148

152149
// Filter Filter the values by the given predicate function (predicate func, slice)
153150
func Filter[T any](fn func(T, int) bool, input ...T) []T {
154-
var list = make([]T, len(input))
151+
list := make([]T, len(input))
155152

156-
var newLen = 0
153+
newLen := 0
157154

158155
for i := range input {
159156
if fn(input[i], i) {
@@ -176,18 +173,18 @@ func Reject[T any](fn func(T, int) bool, input ...T) []T {
176173

177174
// Concat Concat slices
178175
func Concat[T any](mine []T, slices ...[]T) []T {
179-
var mineLen = len(mine)
180-
var totalLen = mineLen
176+
mineLen := len(mine)
177+
totalLen := mineLen
181178

182179
for _, slice := range slices {
183180
if slice == nil {
184181
continue
185182
}
186183

187-
var targetLen = len(slice)
184+
targetLen := len(slice)
188185
totalLen += targetLen
189186
}
190-
var newOne = make([]T, totalLen)
187+
newOne := make([]T, totalLen)
191188

192189
for i, item := range mine {
193190
newOne[i] = item
@@ -199,8 +196,8 @@ func Concat[T any](mine []T, slices ...[]T) []T {
199196
continue
200197
}
201198

202-
var target = slice
203-
var targetLen = len(target)
199+
target := slice
200+
targetLen := len(target)
204201
for j, item := range target {
205202
newOne[totalIndex+j] = item
206203
}
@@ -970,7 +967,7 @@ func PMap[T any, R any](f TransformerFunctor[T, R], option *PMapOption, list ...
970967
return make([]R, 0)
971968
}
972969

973-
var worker = len(list)
970+
worker := len(list)
974971
if option != nil {
975972
if option.FixedPool > 0 && option.FixedPool < worker {
976973
worker = option.FixedPool
@@ -1354,7 +1351,6 @@ func UniqBy[T any, R comparable](identify TransformerFunctor[T, R], list ...T) [
13541351

13551352
// Flatten creates a new slice where one level of nested elements are unnested
13561353
func Flatten[T any](list ...[]T) []T {
1357-
13581354
result := make([]T, 0)
13591355

13601356
// for _, v := range list {
@@ -1942,8 +1938,7 @@ type ProductType struct {
19421938
}
19431939

19441940
// NilTypeDef NilType implemented by Nil determinations
1945-
type NilTypeDef struct {
1946-
}
1941+
type NilTypeDef struct{}
19471942

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

fp_test.go

Lines changed: 11 additions & 13 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 ...int) []int {
35+
fn01 := func(args ...int) []int {
3636
val := args[0]
3737
return SliceOf(val + 1)
3838
}
39-
var fn02 = func(args ...int) []int {
39+
fn02 := func(args ...int) []int {
4040
val := args[0]
4141
return SliceOf(val + 2)
4242
}
43-
var fn03 = func(args ...int) []int {
43+
fn03 := func(args ...int) []int {
4444
val := args[0]
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) {
@@ -84,7 +83,6 @@ func TestFPFunctions(t *testing.T) {
8483
var actualMap map[int]int
8584

8685
fib := func(n int) int {
87-
8886
result, _ := Trampoline(func(input ...int) ([]int, bool, error) {
8987
n := input[0]
9088
a := input[1]
@@ -287,9 +285,9 @@ func TestCurry(t *testing.T) {
287285
}
288286

289287
func TestCompType(t *testing.T) {
290-
var compTypeA = DefProduct(reflect.Int, reflect.String)
291-
var compTypeB = DefProduct(reflect.String)
292-
var myType = DefSum(NilType, compTypeA, compTypeB)
288+
compTypeA := DefProduct(reflect.Int, reflect.String)
289+
compTypeB := DefProduct(reflect.String)
290+
myType := DefSum(NilType, compTypeA, compTypeB)
293291

294292
assert.Equal(t, true, myType.Matches((1), ("1")))
295293
assert.Equal(t, true, myType.Matches(("2")))
@@ -302,9 +300,9 @@ func TestCompType(t *testing.T) {
302300
}
303301

304302
func TestPatternMatching(t *testing.T) {
305-
var compTypeA = DefProduct(reflect.Int, reflect.String)
306-
var compTypeB = DefProduct(reflect.String, reflect.String)
307-
var myType = DefSum(NilType, compTypeA, compTypeB)
303+
compTypeA := DefProduct(reflect.Int, reflect.String)
304+
compTypeB := DefProduct(reflect.String, reflect.String)
305+
myType := DefSum(NilType, compTypeA, compTypeB)
308306

309307
assert.Equal(t, true, compTypeA.Matches(1, "3"))
310308
assert.Equal(t, false, compTypeA.Matches(1, 3))
@@ -313,7 +311,7 @@ func TestPatternMatching(t *testing.T) {
313311
assert.Equal(t, true, myType.Matches("1", "3"))
314312
assert.Equal(t, false, myType.Matches(1, 3))
315313

316-
var patterns = []Pattern{
314+
patterns := []Pattern{
317315
InCaseOfKind(reflect.Int, func(x interface{}) interface{} {
318316
return (fmt.Sprintf("Integer: %v", x))
319317
}),
@@ -330,7 +328,7 @@ func TestPatternMatching(t *testing.T) {
330328
return (fmt.Sprintf("got this object: %v", x))
331329
}),
332330
}
333-
var pm = DefPattern(patterns...)
331+
pm := DefPattern(patterns...)
334332
assert.Equal(t, "Integer: 42", pm.MatchFor((42)))
335333
assert.Equal(t, "Hello world", pm.MatchFor(("world")))
336334
assert.Equal(t, "Matched: ccc", pm.MatchFor(("ccc")))

handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (handlerSelf *HandlerDef) Close() {
4343

4444
close(*handlerSelf.ch)
4545
}
46+
4647
func (handlerSelf *HandlerDef) run() {
4748
for fn := range *handlerSelf.ch {
4849
fn()

maybe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,5 +1413,5 @@ func (noneSelf noneDef) Kind() reflect.Kind {
14131413
// None None utils instance
14141414
var None = noneDef{someDef[any]{isNil: true, isPresent: false}}
14151415

1416-
//var noneAsSome = someDef[interface{}](None)
1416+
// var noneAsSome = someDef[interface{}](None)
14171417
var noneAsSome = None.someDef

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[interface{}]
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
@@ -37,12 +37,10 @@ func MonadIONewGenerics[T any](effect func() T) *MonadIODef[T] {
3737

3838
// FlatMap FlatMap the MonadIO by function
3939
func (monadIOSelf *MonadIODef[T]) FlatMap(fn func(T) *MonadIODef[T]) *MonadIODef[T] {
40-
4140
return &MonadIODef[T]{effect: func() T {
4241
next := fn(monadIOSelf.doEffect())
4342
return next.doEffect()
4443
}}
45-
4644
}
4745

4846
// Subscribe Subscribe the MonadIO by Subscription
@@ -63,8 +61,8 @@ func (monadIOSelf *MonadIODef[T]) ObserveOn(h *HandlerDef) *MonadIODef[T] {
6361
monadIOSelf.obOn = h
6462
return monadIOSelf
6563
}
66-
func (monadIOSelf *MonadIODef[T]) doSubscribe(s *Subscription[T], obOn *HandlerDef, subOn *HandlerDef) *Subscription[T] {
6764

65+
func (monadIOSelf *MonadIODef[T]) doSubscribe(s *Subscription[T], obOn *HandlerDef, subOn *HandlerDef) *Subscription[T] {
6866
if s.OnNext != nil {
6967
var result T
7068

@@ -89,6 +87,7 @@ func (monadIOSelf *MonadIODef[T]) doSubscribe(s *Subscription[T], obOn *HandlerD
8987

9088
return s
9189
}
90+
9291
func (monadIOSelf *MonadIODef[T]) doEffect() T {
9392
return monadIOSelf.effect()
9493
}

network/simpleHTTP.go

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

220220
// DoRequest Do HTTP Request with interceptors
221221
func (simpleHTTPSelf *SimpleHTTPDef) DoRequest(request *http.Request) *ResponseWithError {
222-
223222
response, err := simpleHTTPSelf.client.Do(request)
224223

225224
return &ResponseWithError{
@@ -467,7 +466,6 @@ func APIMakeDoNewRequestWithMultipartSerializer[R any](simpleAPISelf *SimpleAPID
467466
func APIMakeDoNewRequest[R any](simpleAPISelf *SimpleAPIDef, method string, relativeURL string) APINoBody[R] {
468467
return APINoBody[R](func(pathParam PathParam, target *R) *fpgo.MonadIODef[*APIResponse[R]] {
469468
return fpgo.MonadIONewGenerics[*APIResponse[R]](func() *APIResponse[R] {
470-
471469
ctx, cancel := simpleAPISelf.GetSimpleHTTP().GetContextTimeout()
472470
defer cancel()
473471
response := simpleAPISelf.simpleHTTP.DoNewRequest(ctx, simpleAPISelf.DefaultHeader.Clone(), method, simpleAPISelf.replacePathParams(relativeURL, pathParam))

network/simpleHTTP_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ func TestSimpleAPI(t *testing.T) {
3232
var actualContentType string
3333

3434
postsHandler := http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
35-
3635
actualRequestBody, _ = ioutil.ReadAll(req.Body)
3736

3837
// auth := req.Header.Get("Auth")
@@ -172,7 +171,6 @@ func TestSimpleAPIMultipart(t *testing.T) {
172171
var actualContentType string
173172

174173
postsHandler := http.HandlerFunc(func(writer http.ResponseWriter, req *http.Request) {
175-
176174
actualRequestBody, _ = ioutil.ReadAll(req.Body)
177175

178176
// auth := req.Header.Get("Auth")
@@ -211,8 +209,8 @@ func TestSimpleAPIMultipart(t *testing.T) {
211209

212210
actualContentType = ""
213211
postsPost := APIMakePostMultipartBody[PostListResponse](api, "posts")
214-
sentValues = map[string][]string{"userId": []string{"0"}, "id": []string{"5"}, "title": []string{"aa"}, "body": []string{""}}
215-
sentFiles := map[string][]string{"file": []string{filePath}}
212+
sentValues = map[string][]string{"userId": {"0"}, "id": {"5"}, "title": {"aa"}, "body": {""}}
213+
sentFiles := map[string][]string{"file": {filePath}}
216214
apiResponse = postsPost(nil, &MultipartForm{Value: sentValues, File: sentFiles}, &PostListResponse{}).Eval()
217215
assert.Equal(t, nil, apiResponse.Err)
218216
_, params, _ = mime.ParseMediaType(actualContentType)
@@ -223,7 +221,7 @@ func TestSimpleAPIMultipart(t *testing.T) {
223221

224222
actualContentType = ""
225223
postsPut := APIMakePutMultipartBody[PostListResponse](api, "posts")
226-
sentValues = map[string][]string{"userId": []string{"0"}, "id": []string{"4"}, "title": []string{"bb"}, "body": []string{""}}
224+
sentValues = map[string][]string{"userId": {"0"}, "id": {"4"}, "title": {"bb"}, "body": {""}}
227225
apiResponse = postsPut(nil, &MultipartForm{Value: sentValues}, &PostListResponse{}).Eval()
228226
assert.Equal(t, nil, apiResponse.Err)
229227
_, params, _ = mime.ParseMediaType(actualContentType)
@@ -234,7 +232,7 @@ func TestSimpleAPIMultipart(t *testing.T) {
234232

235233
actualContentType = ""
236234
postsPatch := APIMakePatchMultipartBody[PostListResponse](api, "posts")
237-
sentValues = map[string][]string{"userId": []string{"0"}, "id": []string{"3"}, "title": []string{"cc"}, "body": []string{""}}
235+
sentValues = map[string][]string{"userId": {"0"}, "id": {"3"}, "title": {"cc"}, "body": {""}}
238236
apiResponse = postsPatch(nil, &MultipartForm{Value: sentValues}, &PostListResponse{}).Eval()
239237
assert.Equal(t, nil, apiResponse.Err)
240238
_, params, _ = mime.ParseMediaType(actualContentType)

publisher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (publisherSelf *PublisherDef[T]) Publish(result T) {
9595
}
9696
}
9797
}
98+
9899
func (publisherSelf *PublisherDef[T]) doSubscribeSafe(fn func()) {
99100
publisherSelf.subscribeM.Lock()
100101
fn()

publisher_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ func TestPublisher(t *testing.T) {
1111
p := Publisher.New()
1212
p2 := p
1313

14-
var actual = 0
15-
var expected = 0
14+
actual := 0
15+
expected := 0
1616
assert.Equal(t, expected, actual)
1717
assert.Equal(t, true, s == nil)
1818

queue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ func (q *BufferedChannelQueue[T]) freeNodePool() {
500500
}
501501
}
502502
}
503+
503504
func (q *BufferedChannelQueue[T]) loadFromPool() {
504505
for range q.loadWorkerCh {
505506

@@ -532,6 +533,7 @@ func (q *BufferedChannelQueue[T]) loadFromPool() {
532533

533534
}
534535
}
536+
535537
func (q *BufferedChannelQueue[T]) notifyWorkers() {
536538
q.lock.RLock()
537539
if q.pool.Count() > 0 {

0 commit comments

Comments
 (0)