role

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrRenAll    = errors.New("cannot rename everyone, only people tied to specific roles can be renamed")
	ErrNoName    = errors.New("a name of the person must be provided")
	ErrNoReplace = errors.New("a replacement name must be provided")
	ErrRole      = errors.New("unknown role")
)

Functions

func Clean

func Clean(name string, r Role) (ok bool)

Clean fixes and saves a malformed name.

func CleanS

func CleanS(s string) string

CleanS separates and fixes the substrings of s.

func List

func List(role Role) (people []string, total int, err error)

List people filtered by a role.

Example
package main

import (
	"fmt"

	"github.com/Defacto2/df2/pkg/people/internal/role"
)

func main() {
	r := role.Musicians
	_, total, err := role.List(r)
	if err != nil {
		fmt.Print(err)
	}
	fmt.Printf("%s found? %v", r, total > 0)
}
Output:

musicians found? true

func PeopleStmt

func PeopleStmt(role Role, softDel bool) string

PeopleStmt returns a complete SQL WHERE statement for people that are filtered by roles.

func Rename

func Rename(replacement, name string, r Role) (count int64, err error)

Rename replaces the persons using name with the replacement. The task must be limited names associated to a Role.

func Trim

func Trim(s string) string

Trim fixes any malformed strings.

Types

type Role

type Role int

Role are jobs that categorize persons.

Example
package main

import (
	"fmt"

	"github.com/Defacto2/df2/pkg/people/internal/role"
)

func main() {
	r := role.Musicians
	fmt.Println(r)
}
Output:

musicians
const (
	Everyone  Role = iota // Everyone displays all people.
	Artists               // Artists are graphic or video.
	Coders                // Coders are programmers.
	Musicians             // Musicians create music or audio.
	Writers               // Writers for the documents.
)

func Roles

func Roles(r string) Role

func (Role) String

func (r Role) String() string

Jump to

Keyboard shortcuts

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