utils

package
v0.0.0-...-00b6d64 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MESSAGE = "! Seja bem-vindo de volta ao Gophimation"

Variables

This section is empty.

Functions

func CleanCache

func CleanCache(cacheDuration time.Duration)

CleanCache clears the cache, expecting a parameter named cacheDuration of type time.Duration that determines the maximum duration a cache file is allowed to exist before being deleted.

func Clear

func Clear()

Clear runs the command to clear the terminal

func CreateFile

func CreateFile(rootDir string, filename string)

CreateFile prompts the user to enter their name, creates a new file with the specified name, and writes the user's name to the file as JSON data in a UserConfig struct format.

func GetCacheDir

func GetCacheDir(folderName string) string

GetCacheDir retrieves the cache directory. It expects a parameter 'folderName' that specifies the desired folder name.

func GetUserInput

func GetUserInput(message string) int

GetUserInput retrieves user input by displaying a message in the console.

func Greeting

func Greeting(userName string)

Greeting is a function that takes a user name and outputs a greeting message based on the time of day. It gets the current hour using the time package and uses a switch statement to determine the appropriate message. The function then prints the greeting message to the console.

func OptionIsValid

func OptionIsValid(anime []entity.Anime, selectedOption int)

OptionIsValid checks if the option selected by the user is valid for a given list of anime.

func PlayVideo

func PlayVideo(videoUrl, nameEpisode string)

PlayVideo runs a command that opens a video player to play a video from a specified URL

func ReadFile

func ReadFile(rootDir string, fileName string)

ReadFile reads the specified file and unmarshals its JSON content into a UserConfig struct. It then calls the Greeting function to display a welcome message for the user.

Types

type UserConfig

type UserConfig struct {
	Name string `json:"name"`
}

UserConfig stores user configuration information, including their name.

Jump to

Keyboard shortcuts

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