Functional library for Golang programmers. Inspired by Ramda JS and Lodash
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main() {
input := 1
gofunc.AddInt(input) // Expected: 1
gofunc.AddInt(1,2,3) // Expected: 6
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main() {
input := "Hello"
gofunc.AddString(input) // Expected: Hello
gofunc.AddString(input, "world") // Expected: Hello world
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main () {
input := []int{3,3,3}
input2 := []string{"hey","hey"}
checkAllElementIs3 := gofunc.All(3)
checkAllElementIs3(input) // Return true
checkAllElementIs3(input2) // Return false
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main() {
input := [3]int {1,2,3}
gofunc.First(input) // Expected: 1
stringInput := [3]string {"Hello", "Go", "developers"}
gofunc.First(stringInput) // Expected: Hello
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main() {
input := [3]int {1,2,3}
gofunc.Last(input) // Expected: 3
stringInput := [3]string {"Hello", "Go", "developers"}
gofunc.Last(stringInput) // Expected: developers
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main () {
array := []int{1, 2, 3}
gofunc.Sum(array) // Expected: 6
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
func main () {
alwaysTrue := gofunc.Always(true)
alwaysTrue() // return true
}
Example:
import (
gofunc "https://github.com/MinhPhu0304/gofunc"
)
type Person struct {
Name string
}
func main () {
test := Person{Name: "test"}
name := gofunc.Prop("Name", test) // Return "test"
}