๐Ÿ’พ Archived View for source.community โ€บ Fuwn โ€บ space โ€บ blob โ€บ main โ€บ pkg โ€บ utilities โ€บ utilities.go captured on 2024-02-05 at 10:02:00. Gemini links have been rewritten to link to archived content

View Raw

More Information

โฌ…๏ธ Previous capture (2023-07-10)

๐Ÿšง View Differences

-=-=-=-=-=-=-

                                                         .
,-. ,-. . . ,-. ,-. ,-.    ,-. ,-. ,-,-. ,-,-. . . ,-. . |- . .
`-. | | | | |   |   |-'    |   | | | | | | | | | | | | | |  | |
`-' `-' `-^ '   `-' `-' :: `-' `-' ' ' ' ' ' ' `-^ ' ' ' `' `-|
                                                             /|
                                                            `-'

Profile for Fuwn

Fuwn / space

git clone https://source.community/Fuwn/space.git

Branches

Log

Tree

/pkg/utilities/utilities.go (main)

โ†‘ /pkg/utilities

blob

View raw contents of /pkg/utilities/utilities.go (main)

โ”€โ”€โ”€โ”€โ•ฎ
   1โ”‚ // Copyright (C) 2021-2021 Fuwn
   2โ”‚ // SPDX-License-Identifier: GPL-3.0-only
   3โ”‚ 
   4โ”‚ package utilities
   5โ”‚ 
   6โ”‚ import (
   7โ”‚ 	"math/rand"
   8โ”‚ 	"os"
   9โ”‚ 	"time"
  10โ”‚ 	"unicode/utf8"
  11โ”‚ 
  12โ”‚ 	"github.com/spf13/viper"
  13โ”‚ )
  14โ”‚ 
  15โ”‚ func init() {
  16โ”‚ 	rand.Seed(time.Now().UnixNano())
  17โ”‚ }
  18โ”‚ 
  19โ”‚ func GetRandomQuote() string {
  20โ”‚ 	quotes := viper.GetStringSlice("space.footer.quotes")
  21โ”‚ 
  22โ”‚ 	return quotes[rand.Intn(len(quotes))]
  23โ”‚ }
  24โ”‚ 
  25โ”‚ func GetCopyright() string {
  26โ”‚ 	return viper.GetString("space.footer.copyright")
  27โ”‚ }
  28โ”‚ 
  29โ”‚ // DoesFilesExist Check if the following files exist, return files that don't exist
  30โ”‚ func DoesFilesExist(files []string) []string {
  31โ”‚ 	var nonExistent []string
  32โ”‚ 
  33โ”‚ 	for _, file := range files {
  34โ”‚ 		// https://stackoverflow.com/a/12518877
  35โ”‚ 		if _, err := os.Stat(file); os.IsNotExist(err) {
  36โ”‚ 			nonExistent = append(nonExistent, file)
  37โ”‚ 		}
  38โ”‚ 	}
  39โ”‚ 
  40โ”‚ 	return nonExistent
  41โ”‚ }
  42โ”‚ 
  43โ”‚ func TrimLastChar(s string) string {
  44โ”‚ 	r, size := utf8.DecodeLastRuneInString(s)
  45โ”‚ 	if r == utf8.RuneError && (size == 0 || size == 1) {
  46โ”‚ 		size = 0
  47โ”‚ 	}
  48โ”‚ 	return s[:len(s)-size]
  49โ”‚ }
โ”€โ”€โ”€โ”€โ•ฏ

ยท ยท ยท

๐Ÿก Home

FAQs

Privacy Policy

Terms & Conditions

Official Gemlog

info@source.community

ยฉ 2024 source.community