Skip to content
iFurySt edited this page Jul 28, 2023 · 9 revisions

Welcome to the 👾 lol wiki!

bool

NewTrue & NewFalse

Just for convenience, you create the pointer to a Boolean value on one line.

package main

import (
	"github.com/ifuryst/lol"
	"net"
)

type IP struct {
	Address string
	Status  *bool
}

func main() {
	s := IP{
		Address: net.ParseIP("8.8.8.8").String(),
		Status:  lol.NewFalse(),
	}
	// do sth
	_ = s
}

map

Keys

Get the all keys in the map struct.

package main

import (
	"fmt"
	"github.com/ifuryst/lol"
)

func main() {
	users := map[string]int{
		"Jack":       18,
		"Tom":        21,
		"Heisenberg": 48,
	}
	fmt.Println(lol.Keys(users))
	// Output:
	// [Jack Tom Heisenberg]
}

Values

Get the all values in the map struct.

package main

import (
	"fmt"
	"github.com/ifuryst/lol"
)

func main() {
	users := map[string]int{
		"Jack":       18,
		"Tom":        21,
		"Heisenberg": 48,
	}
	fmt.Println(lol.Values(users))
	// Output:
	// [18 21 48]
}

math

Abs

Get the absolute value of the given number.

package main

import (
	"fmt"
	"github.com/ifuryst/lol"
)

func main() {
	n := -3
	fmt.Println(lol.Abs(n))
	// Output:
	// 3
}

Max & Min

Get the maximum or minimum number from the given numbers.

package main

import (
	"fmt"
	"github.com/ifuryst/lol"
)

func main() {
	i, j := -3, 3
	fmt.Println(lol.Max(i, j))
	fmt.Println(lol.Min(i, j))
	// Output:
	// 3
	// -3
}
Clone this wiki locally