gou

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 1 Imported by: 1

README

Gabtec-Gou

This is my first published Go package.

It's called gabtec-gou, because "gou" stands for "Go Utils" 😄

Usage

# create a new project
# after you have your go.mod file setup
# run:
$ go get -u github.com/gabtec/gabtec-gou

Then use it, like this:

// e.g. in your main.go file

package main

import "github.com/gabtec/gabtec-gou"

func main() {
  myVar := gou.GetEnv("TheEnvVarName_aka_key", "Some_default_value_in_case_envVar_not_set_or_not_found")
  //...
}

Available Functions

💼 GetEnv(key, defaultValue string) string {}
💼 StrSlice(s string, n int) string {}
💼 SliceContainsString(slice []string, str string) bool {}

Testing

# to run tests, do:
$ go test -v ./...

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(key, defaultValue string) string

GetEnv reads the env variable specified by "key", or set a default value if the var not found

Parameters:

  • key: string - The env variable name, to get.
  • defaultValue: string - The default value to return, in case key doens't exist.

Returns:

  • string - The string value or it's default value

func MergeMaps added in v0.2.0

func MergeMaps(a, b map[string]interface{}) map[string]interface{}

MergeMaps will merge together 2 maps of type map[string]interface{} the values of the 2nd map, if already existent in 1st map, will override

Parameters:

  • a: map[string]interface{} - The 1st map to merge
  • b: map[string]interface{} - The 2nd map to merge

Returns:

  • map[string]interface{} - The resulting merged map

func MergeStringMaps added in v0.3.0

func MergeStringMaps(a, b map[string]string) map[string]string

MergeStringMaps will merge together 2 maps of type map[string]string the values of the 2nd map, if already existent in 1st map, will override

Parameters:

  • a: map[string]string - The 1st map to merge
  • b: map[string]string - The 2nd map to merge

Returns:

  • map[string]string - The resulting merged map

func SliceContainsString added in v0.2.0

func SliceContainsString(slice []string, str string) bool

SliceContainsString checks if a given string exists in a strings slice.

Parameters:

  • slice: []string - The source slice where to check for the existence of a specific string.
  • str: string - The string to check.

Returns:

  • bool - True if the string is found in the slice.

func StrSlice added in v0.1.0

func StrSlice(s string, n int) string

StrSlice slices a given string "s", from 1st char until the given "n"'th char

Parameters:

  • s: string - The source string.
  • n: int - The number of chars to include.

Returns:

  • string - The resulting sub-string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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