This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package helpers | |
func DoesSliceIncludesInt(value int, slice []int) bool { | |
for _, i := range slice { | |
if value == i { | |
return true | |
} | |
} | |
return false | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model | |
type Ingredient struct { | |
ID int `json:"id"` | |
Name string `json:"name"` | |
Price float32 `json:"price"` | |
Quantity int `json:"quantity"` | |
Unit string `json:"unit"` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/thoas/go-funk" | |
) | |
func main() { | |
result := funk.Contains([]int{1, 2, 3, 4, 5}, 3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/thoas/go-funk" | |
) | |
func main() { | |
baseSlice := []int{1, 2, 3, 4, 5} | |
sum := funk.Reduce(baseSlice, func(acc, elem int) int { return acc + elem }, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/thoas/go-funk" | |
) | |
func main() { | |
baseSlice := []int{1, 2, 3, 4, 5} | |
newSlice := funk.Filter(baseSlice, func(x int) bool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/thoas/go-funk" | |
) | |
func main() { | |
baseSlice := []int{1, 2, 3, 4, 5} | |
newSlice := funk.Map(baseSlice, func(x int) int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/thoas/go-funk" | |
) | |
func main() { | |
baseSlice := []int{1, 2, 3, 4, 5} | |
newSlice := funk.Map(baseSlice, func(x int) int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Contains(in interface{}, elem interface{}) bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fmt.Println("UserAgent", r.Headers.Get("User-Agent")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extensions.RandomUserAgent(c) |