users

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package users implements operations for user data manipulation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equals

func Equals(a, b models.User) bool

Equals returns true if both users have same nickname, password and mac address.

func Filter added in v0.3.0

func Filter(users []models.User, filters ...FilterFunc) []models.User

Filter returns slice of users that passed all given FilterFunc tests. If no filters given, returns exactly same slice of users that has been passed to function.

func Online added in v0.3.0

func Online(u models.User) bool

Online returns true if given user is currently online.

func Private added in v0.3.0

func Private(u models.User) bool

Private returns true if given user has private flag set to true.

func PublicSlice

func PublicSlice(u []models.User) []models.UserPublicData

PublicSlice returns new slice with only public user data, created from given slice containing full user data.

func StrictEquals

func StrictEquals(a, b models.User) bool

StrictEquals returns true if both users have same values assigned to every field.

func Update

func Update(old models.User, c *Changes) models.User

Update applies given changes to given user model and returns new user model.

Types

type Changes

type Changes struct {
	Nickname string
	Password []byte
	Online   *bool
}

Changes represents possible changes that can be applied to models.User

type FilterFunc added in v0.3.0

type FilterFunc func(models.User) bool

FilterFunc accepts User model and returns true or false.

func DefaultFilters added in v0.3.0

func DefaultFilters() []FilterFunc

DefaultFilters returns slice with convenient collection of default filters that can be used for outputting user data.

For example: default filters contains Not(Private) filter for hiding private users.

func Not added in v0.3.0

func Not(f FilterFunc) FilterFunc

Not returns opposite of given FilterFunc result.

Jump to

Keyboard shortcuts

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