Documentation
¶
Overview ¶
Package config provides functionality for managing a user's mods.
Copyright © 2021 Matthew Champagne <mmchamp95@gmail.com>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
const ModsKey = "mods"
ModsKey is the key used to store managed mods.
Variables ¶
var ErrNoMods = errors.New("no mods being managed")
ErrNoMods is returned when there are no mods being managed.
var ErrNotSet = errors.New("not set")
ErrNotSet is returned when a mod slug Dependency has not been set.
Functions ¶
func DepMapSync ¶
func DepMapSync() (map[string]*Dependency, error)
DepMapSync safely returns a map of mod slugs to Dependencies for the user's configuration file.
func SetDep ¶
func SetDep(slug string, dep *Dependency) error
SetDep safely sets Dependency information for a given mod's slug.
Types ¶
type Dependency ¶
type Dependency struct { ID uint `mapstructure:"id"` Name string `mapstructure:"name"` File string `mapstructure:"file"` Uploaded time.Time `mapstructure:"uploaded"` Size uint `mapstructure:"size"` }
Dependency is a mod managed in the user's dependency configuration file.
func Dep ¶
func Dep(slug string) (*Dependency, error)
Dep safely returns a Dependency for a given mod's slug.
type DependencyMap ¶
type DependencyMap struct {
// contains filtered or unexported fields
}
DependencyMap allows for safe concurrent usage of the map of a user's mod dependencies.
func DepMap ¶
func DepMap() (*DependencyMap, error)
DepMap safely returns a concurrency safe map of mod slugs to Dependencies for the user's configuration file.
func (*DependencyMap) Delete ¶
func (d *DependencyMap) Delete(slug string)
Delete safely removes a Dependency for a given mod's slug if it's present in the map.
func (*DependencyMap) Get ¶
func (d *DependencyMap) Get(slug string) (*Dependency, bool)
Get safely returns a Dependency for a given mod's slug if it's present in the map.
func (*DependencyMap) Set ¶
func (d *DependencyMap) Set(slug string, dep *Dependency)
Set safely sets the Dependency for a given mod's slug.
func (*DependencyMap) Write ¶
func (d *DependencyMap) Write() error
Write safely writes all Dependency map information.