freeze

package module
v0.0.0-...-cde8d86 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2016 License: MIT Imports: 2 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

freeze package

Go Report Card

[GoDoc] (https://godoc.org/github.com/dns-gh/freeze)

Simple wrapper over the time and rand packages to make more complex behaviors around random sleep functionalities

Motivation

Used in other projects such as the Twitter Bot or the Nasa Neo Client

Installation

  • It requires Go language of course. You can set it up by downloading it here: https://golang.org/dl/
  • Install it here C:/Go.
  • Set your GOPATH, GOROOT and PATH environment variables:
export GOROOT=C:/Go
export GOPATH=WORKING_DIR
export PATH=C:/Go/bin:${PATH}
  • Download and install the package:
@working_dir $ go get github.com/dns-gh/freeze/...
@working_dir $ go install github.com/dns-gh/freeze

Usage

package main

import "github.com/dns-gh/freeze"

func main() {
	freeze.Sleep(10) // sleeps randomly from 0 to 9 seconds
    freeze.MaybeSleepMinMax(1,10,20,30) // 1 chance over 10 to sleep from 10 to 30 seconds
}

Tests

TODO

LICENSE

See included LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRandomElement

func GetRandomElement(tab []string) string

GetRandomElement returns a random element from a given slice

func MaybeSleepMinMax

func MaybeSleepMinMax(chance, totalChance, min, max int)

MaybeSleepMinMax sleeps for a random duration from 'min' to 'max' seconds with a chance of 'chance' / 'totalChance'

func Sleep

func Sleep(duration int)

Sleep sleeps for a random duration from 0 to 'duration' seconds

func SleepMinMax

func SleepMinMax(min, max int)

SleepMinMax sleeps for a random duration from 'min' to 'max' seconds

Types

This section is empty.

Jump to

Keyboard shortcuts

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