util

package
v0.0.0-...-c4bfc47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(slice []string, text string) bool

Contains checks if a string slice contains a specified string

func Difference

func Difference(slice []string, slice2 []string) (difference []string)

Difference returns the difference of slice and slice2

func GetMessage

func GetMessage(locale, tag string) string

GetMessage retrieves a message tag and returns a random message chose from res/datasets/messages.json

func Index

func Index(slice []string, text string) int

Index returns a string index in a string slice

func ReadFile

func ReadFile(path string) (bytes []byte)

ReadFile returns the bytes of a file searched in the path and beyond it

Types

type Message

type Message struct {
	Tag      string   `json:"tag"`
	Messages []string `json:"messages"`
}

Message contains the message's tag and its contained matched sentences

func GetMessageByTag

func GetMessageByTag(tag, locale string) Message

GetMessageByTag returns a message found by the given tag and locale

func GetMessages

func GetMessages(locale string) []Message

GetMessages returns the cached messages for the given locale

func SerializeMessages

func SerializeMessages(locale string) []Message

SerializeMessages serializes the content of `res/datasets/messages.json` in JSON

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL