speedtest

package
v0.0.0-...-bb60f61 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package speedtest contains methods for performing internet speed tests using speedtest.net.

Index

Constants

This section is empty.

Variables

View Source
var ErrStatus = errors.New("unexpected status code")

ErrStatus is the error given when an HTTP call to speedtest.net returns an error status code.

Functions

This section is empty.

Types

type Client

type Client struct {
	IP        string `xml:"ip,attr"`
	Latitude  string `xml:"lat,attr"`
	Longitude string `xml:"lon,attr"`
	ISP       string `xml:"isp,attr"`
}

The Client type contains information about the client performing a speed test.

type GetClientsResponse

type GetClientsResponse struct {
	Clients []Client `xml:"client"`
}

GetClientsResponse is the response DTO used when getting the speed test client info.

type GetServersResponse

type GetServersResponse struct {
	Servers []Server `xml:"servers>server"`
}

GetServersResponse is the response DTO used when getting test server info.

type Results

type Results struct {
	Latency  float64
	Download float64
	Upload   float64
}

The Results type contains the results of a speed test.

type Server

type Server struct {
	URL       string `xml:"url,attr"`
	Latitude  string `xml:"lat,attr"`
	Longitude string `xml:"lon,attr"`
	Name      string `xml:"name,attr"`
	Country   string `xml:"country,attr"`
	Sponsor   string `xml:"sponsor,attr"`
	ID        string `xml:"id,attr"`
	URL2      string `xml:"url2,attr"`
	Host      string `xml:"host,attr"`
}

The Server type contains information about a server that can be used to perform a speed test.

type Tester

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

The Tester type is responsible for performing internet speed tests.

func New

func New() *Tester

New returns a new instance of the Tester type that can perform a speed test.

func (*Tester) Ping

func (t *Tester) Ping() error

Ping returns a non-nil error if speedtest.net appears to be down.

func (*Tester) Test

func (t *Tester) Test(ctx context.Context) (Results, error)

Test performs a speed test and returns the results. Can be cancelled using the given context.

Jump to

Keyboard shortcuts

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