{"id":25019157,"url":"https://github.com/parinpan/fun-go","last_synced_at":"2025-04-13T03:42:08.281Z","repository":{"id":64299613,"uuid":"202593228","full_name":"parinpan/fun-go","owner":"parinpan","description":"Fun-go is the answer when you are sick of writing over and over again a looping block that seems giving much redundancy in your project.","archived":false,"fork":false,"pushed_at":"2019-08-27T15:22:28.000Z","size":24,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T20:51:30.541Z","etag":null,"topics":["array-manipulations","array-methods","functional-programming","golang","library","slice"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parinpan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-15T18:38:32.000Z","updated_at":"2022-01-15T00:05:37.000Z","dependencies_parsed_at":"2023-01-15T09:15:29.763Z","dependency_job_id":null,"html_url":"https://github.com/parinpan/fun-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parinpan%2Ffun-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parinpan%2Ffun-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parinpan%2Ffun-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parinpan%2Ffun-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parinpan","download_url":"https://codeload.github.com/parinpan/fun-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661025,"owners_count":21141381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array-manipulations","array-methods","functional-programming","golang","library","slice"],"created_at":"2025-02-05T11:39:01.155Z","updated_at":"2025-04-13T03:42:08.259Z","avatar_url":"https://github.com/parinpan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# fun-go by Fachrin Aulia\n\n\u003e This is the newest version of [Go-JS Array](https://github.com/parinpan/gojs-array) that I used to create in advance. Now Fun-go supports generic slice struct type which means you can use any kind of slice struct as an input.\n\nFun-go is the answer when you are sick of writing over and over again a looping block that seems giving much redundancy in your project. It's inspired by Javascript programming language to approach a better functional programming paradigm using Golang that at least currently doesn't support iteration methods.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\tfungo \"github.com/parinpan/fun-go\"\n)\n\n/*\n\tSoftware Engineer: Fachrin Aulia Nasution\n\tAn always in beta software engineer\n*/\n\nfunc main() {\n\t// ProductList -\u003e []ProductList{...}\n\tproductSlice := fungo.NewSlice(ProductList)\n\n\t// get all product which has official store shop\n\tproductsFromOS, _ := productSlice.Filter(func(value interface{}, index int) bool {\n\t\tproduct := value.(Product)\n\t\treturn product.Shop.IsOfficialStore\n\t}).([]Product)\n\n\t// get slice of product names string\n\tproductNames, _ := productSlice.Map(func(value interface{}, index int) interface{} {\n\t\treturn value.(Product).Name\n\t}).([]string)\n\n\t// get total of product price in the list\n\tproductsPriceTotal := productSlice.Reduce(func(accumulator int64, value interface{}) int64 {\n\t\treturn accumulator + int64(value.(Product).Price)\n\t})\n\n\t// print all product names\n\tproductNameSlice := fungo.NewSlice(productNames)\n\t/*\n\t\tOutput:\n\t\t  Kemeja\n\t\t  Vas\n\t\t  Dompet\n\t\t  Laptop\n\t\t  Dispenser\n\t*/\n\tproductNameSlice.ForEach(func(value interface{}, index int) {\n\t\tfmt.Println(value.(string))\n\t})\n\n\t// output: Product Price Total: 15000\n\tfmt.Println(fmt.Sprint(\"Product Price Total: \", productsPriceTotal))\n\n\t// output: []main.Product{main.Product{ID:1, Name:\"Kemeja\", Price:1000, Shop:main.Shop{Name:\"shop #1\", IsOfficialStore:true}}, main.Product{ID:3, Name:\"Dompet\", Price:3000, Shop:main.Shop{Name:\"shop #3\", IsOfficialStore:true}}, main.Product{ID:5, Name:\"Dispenser\", Price:5000, Shop:main.Shop{Name:\"shop #5\", IsOfficialStore:true}}}\n\tfmt.Printf(\"%#v\\n\", productsFromOS)\n}\n```\n\nTo try the program above, execute with this command:\n`cd $GOPATH/src/github.com/parinpan/fun-go/pkg/playground \u0026\u0026 go run main.go marketplace.go`\n\nBenchmark Result tested on **MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports) 2 GHz Intel Core i5 8 GB 1867 MHz LPDDR3** with 1.000.000 slice elements of struct can be found in the test file.\n```\ngoos: darwin\ngoarch: amd64\npkg: github.com/parinpan/fun-go\nBenchmarkFunctionalIteratorMap/functionalIterator-4             2000000000               0.29 ns/op\nBenchmarkFunctionalIteratorMap/normalIterator-4                 2000000000               0.13 ns/op\nBenchmarkFunctionalIteratorFilter/functionalIterator-4          2000000000               0.14 ns/op\nBenchmarkFunctionalIteratorFilter/normalIterator-4              2000000000               0.05 ns/op\nBenchmarkFunctionalIteratorForEach/functionalIterator-4         2000000000               0.03 ns/op\nBenchmarkFunctionalIteratorForEach/normalIterator-4             2000000000               0.00 ns/op\nBenchmarkFunctionalIteratorReduce/functionalIterator-4          2000000000               0.03 ns/op\nBenchmarkFunctionalIteratorReduce/normalIterator-4              2000000000               0.00 ns/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparinpan%2Ffun-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparinpan%2Ffun-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparinpan%2Ffun-go/lists"}