fast

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 11 Imported by: 2

README

adhocore/fast

Go Report Lint Donate 15 Donate 25 Donate 50 Tweet

A GO lang command line tool to check internet speed right from the terminal.

Uses fast.com through headless chrome.

Prerequistie

Chrome or Chromium or Brave browser must be installed. chromedp will try to locate the chrome executable automatically from these paths.

If you get error regarding chrome availability, and you have chrome in custom path then check Troubleshooting.

Usage

Install fast binary:

go get -u github.com/adhocore/fast/cmd/fast

or in recent go versions:

go install github.com/adhocore/fast/cmd/fast@v1.2.0

Finally, make sure $GOPATH or $HOME/go/bin is in your $PATH or %path%, then run:

fast

# if you just want download speed (pass -noup aka no upload speed)
fast -noup

Wait a while or Ctrl+C if you can't. That's all.

Integration

You can also integrate fast in your Go projects.

import (
    "github.com/adhocore/chin"
    "github.com/adhocore/fast"
)

// true if you want only download speed
noUpload := false

// Optional, shows a spinner while waiting result,
spin := chin.New()
go spin.Start()

// Prints the output right away:
fast.Run(noUpload)

// OR, to customize print style:
res, err := fast.Measure(noUpload)
// Then use res (`fast.Fast` struct) to print in custom style.

// Stop the spinner finally!
spin.Stop()

Screen

FAST

Troubleshooting

In MacOS, you can do something like this:

echo '#!/bin/sh\n\n/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $@' > /usr/local/bin/chrome

chmod +x /usr/local/bin/chrome

In WSL, you can symlink chrome from host WinOS like this:

sudo ln -s /mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe /usr/local/bin/chrome

In other OS, you can do something equivalent to above. The idea is chrome command should point to Chrome Browser.


Other projects

My other golang projects you might find interesting and useful:

  • gronx - Lightweight, fast and dependency-free Cron expression parser (due checker), task scheduler and/or daemon for Golang (tested on v1.13 and above) and standalone usage.
  • urlsh - URL shortener and bookmarker service with UI, API, Cache, Hits Counter and forwarder using postgres and redis in backend, bulma in frontend; has web and cli client
  • goic - Go Open ID Connect, is OpenID connect client library for Golang, supports the Authorization Code Flow of OpenID Connect specification.
  • chin - A GO lang command line tool to show a spinner as user waits for some long running jobs to finish.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Browsers = map[string][]string{
	"windows": {"", `C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe`},
	"darwin":  {"", `/Applications/Brave Browser.app/Contents/MacOS/BraveBrowser`},
	"*":       {"", `brave`, `brave-browser`},
}

Browsers is list of non default browsers by OS

View Source
var NoColor = os.Getenv("NO_COLOR") != "" || os.Getenv("TERM") == "dumb"

NoColor tells if color should be used

Functions

func Out

func Out(fast *Fast, start time.Time)

Out prints the output to terminal

func Run

func Run(noUp bool)

Run is the ready to use API. For customization call Measure().

Types

type Fast

type Fast struct {
	Up       string
	Down     string
	UpUnit   string
	DownUnit string
}

Fast represents measurement structure

func Measure

func Measure(noUp bool) (*Fast, error)

Measure does the main job. It returns *Fast and error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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