fast

package module
v0.0.0-...-2c17a66 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2019 License: MIT Imports: 12 Imported by: 0

README

go-fast Build Status Doc

fast.com api for go - pure - no headless browser or stuff

This package is the API for https://github.com/ddo/fast

Fast: Minimal zero-dependency utility for testing your internet download speed from terminal

Installation

go get -u gopkg.in/ddo/go-fast.v0

Workflow

  • #New
  • #Init
  • #GetUrls
  • #Measure

Example

fastCom := fast.New()

// init
err := fastCom.Init()
if err != nil {
    panic(err)
}

// get urls
urls, err := fastCom.GetUrls()
if err != nil {
    panic(err)
}

// measure
KbpsChan := make(chan float64)

go func() {
    for Kbps := range KbpsChan {
        fmt.Printf("%.2f Kbps %.2f Mbps\n", Kbps, Kbps/1000)
    }

    fmt.Println("done")
}()

err = fastCom.Measure(urls, KbpsChan)
if err != nil {
    panic(err)
}

Debug

to enable log set environment variable as

DLOG=*

Test

go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fast

type Fast struct {
	// contains filtered or unexported fields
}

Fast contains client config

func New

func New() *Fast

New creates empty Fast instance with a http client

func (*Fast) GetUrls

func (f *Fast) GetUrls() (urls []string, err error)

GetUrls gets the testing urls call after #Init recall if 403 err from download

func (*Fast) Init

func (f *Fast) Init() (err error)

Init inits token and url

func (*Fast) Measure

func (f *Fast) Measure(urls []string, KbpsChan chan<- float64, measureTimeoutMax int, measureTimeoutMin int) (err error)

Measure measures download speeds from given urls

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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