tools

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Helper functions for reading/writing data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterfaceSlice

func InterfaceSlice(slice interface{}) []interface{}

Needed because Go won't let us cast from []FooProto --> []googleProto.Message https://stackoverflow.com/questions/12753805/type-converting-slices-of-interfaces

func ReadCsvFile

func ReadCsvFile(filePath string) [][]string

func ReadFile added in v0.1.14

func ReadFile(filePath string) string

func ReadFileLines

func ReadFileLines(filePath string) []string

func ReadFileLinesOrNil

func ReadFileLinesOrNil(filePath string) []string

func ReadMap

func ReadMap(filePath string) map[string]string

func ReadMapOrNil

func ReadMapOrNil(filePath string) map[string]string

func ReadWeb added in v0.1.14

func ReadWeb(url string) (string, error)

Fetches web results a single url, and returns the page contents as a string.

func ReadWebMulti

func ReadWebMulti(urls []string) []string

Fetches web results from all the given urls, and returns a parallel array of page contents.

func ReadWebMultiMap

func ReadWebMultiMap[K comparable](keys []K, keyToUrl func(K) string) map[K]string

Like ReadWebMulti, but uses a lambda function for converting keys --> urls and returns a map of keys to web contents.

func ReadWebRequired added in v0.1.14

func ReadWebRequired(url string) string

func WriteFile added in v0.1.14

func WriteFile(filePath string, content string)

func WriteFileLines

func WriteFileLines(filePath string, lines []string)

func WriteMap

func WriteMap(filePath string, contents map[string]string)

func WriteMapCustomSort added in v0.1.6

func WriteMapCustomSort(filePath string, contents map[string]string, sortFunc func(a, b string) bool)

func WriteMapSortByIntKey added in v0.1.6

func WriteMapSortByIntKey(filePath string, contents map[string]string)

func WriteProtoArrayToBuilder

func WriteProtoArrayToBuilder(arrInterface interface{}, builder *strings.Builder, name string)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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