Help us shape the future of Go! Take the 2026 Go Developer Survey

platform

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Google Search Console

Index

Constants

View Source
const (
	// Determine if the time will be display as x-axis headers, or something else
	XHeaderTime uint16 = iota
	XHeaderOtherDim
)
View Source
const RequestTimeout = 30 * time.Second

RequestTimeout of the requests to the APIs and websites.

Variables

This section is empty.

Functions

func ConvertDates

func ConvertDates(
	base time.Time,
	startDate string,
	endDate string,
) (start time.Time, end time.Time, err error)

ConvertDates from configuration string values to formatted start date / end date with layout. Example: "next_month" => startDate "2019-01-01", endDate "2019-01-31".

func ExtractCountPeriod

func ExtractCountPeriod(period string) (int64, error)

ExtractCountPeriod from a period like "5_weeks_ago". Return the count of the period, "5" in the case of "5_weeks_ago".

func FetchJSON

func FetchJSON(url string, header string) (gjson.Result, error)

FetchJSON from a URL with a GET request. The header, like "Authorization: Bearer ${TOKEN}", can use environment variables.

func HostBar

func HostBar(runner runnerFunc, command string) (data []int, err error)

func HostBox

func HostBox(runner runnerFunc, command string) (string, error)

func HostCPURate

func HostCPURate(runner runnerFunc) (float64, error)

HostCPURate is the CPU usage, in percent, during half a second. It's the average since the boot if the command doesn't give two samples.

func HostDisk

func HostDisk(runner runnerFunc, headers []string, unit string) ([][]string, error)

func HostDiskIO

func HostDiskIO(runner runnerFunc, unit string, rate bool) (string, error)

HostDiskIO read / written on the physical disks since the boot, or per second with rate.

func HostGauge

func HostGauge(runner runnerFunc, command string) (float64, error)

func HostLoad

func HostLoad(runner runnerFunc) (string, error)

func HostMemory

func HostMemory(runner runnerFunc, metrics []string, unit string) (val []int, err error)

func HostMemoryRate

func HostMemoryRate(runner runnerFunc) (float64, error)

func HostNetIO

func HostNetIO(runner runnerFunc, unit string, rate bool) (string, error)

HostNetIO received / transmitted since the boot, or per second with rate.

func HostProcesses

func HostProcesses(runner runnerFunc) (string, error)

func HostSwapRate

func HostSwapRate(runner runnerFunc) (float64, error)

func HostTable

func HostTable(runner runnerFunc, command string, headers []string) (cells [][]string, err error)

func HostUptime

func HostUptime(runner runnerFunc) (int64, error)

func JSONBars

func JSONBars(root gjson.Result, path string, label string, value string) (labels []string, values []int, err error)

JSONBars of the array at the path: the label and the value of each element.

func JSONTable

func JSONTable(root gjson.Result, path string, fields []string, limit int) ([][]string, error)

JSONTable of the array at the path: one row per element, one column per field.

func JSONValue

func JSONValue(root gjson.Result, path string) (string, error)

JSONValue at the path, as a text. See https://github.com/tidwall/gjson/blob/master/SYNTAX.md for the paths.

func NewHTTPClient

func NewHTTPClient() *http.Client

NewHTTPClient with a timeout.

func NewTerminal

func NewTerminal() (*terminal, error)

NewTerminal initializes the terminal.

Types

type AnalyticValues

type AnalyticValues struct {
	PropertyID string
	StartDate  string
	EndDate    string
	TimePeriod string
	Global     bool
	Metrics    []string
	Dimensions []string
	Filters    []string
	Orders     []string
	RowLimit   int64
	XHeaders   uint16
}

AnalyticValues which can be possibly send to the Google Analytics API. This is a pure value object without behavior.

type Analytics

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

Analytics connect to Google Analytics Data API (GA4).

func NewAnalyticsClient

func NewAnalyticsClient(keyfile string) (*Analytics, error)

NewAnalyticsClient to connect to Google Analytics APIs.

func (*Analytics) BarMetric

func (c *Analytics) BarMetric(val AnalyticValues) ([]string, []int, error)

BarMetric provides a qualitive dimension linked to a quantitative value, for example a date (dimension) with an int.

func (*Analytics) RealTimeUsers

func (c *Analytics) RealTimeUsers(propertyID string) (string, error)

RealTimeUsers return the number of visitor currently on the website.

func (*Analytics) SimpleMetric

func (c *Analytics) SimpleMetric(val AnalyticValues) (string, error)

SimpleMetric get a value depending on Google Analytics metrics.

func (*Analytics) StackedBar

func (c *Analytics) StackedBar(an AnalyticValues) (dim []string, values map[string][]int, err error)

StackedBar returns one dimension set linked with multiple values.

func (*Analytics) Table

func (c *Analytics) Table(
	an AnalyticValues,
	firstHeader string,
) (headers []string, dim []string, u [][]string, err error)

Table display dimensions and values. The headers on the first row are qualitative dimensions, the values can be qualitative or quantitative.

type Feedly

type Feedly struct {
	Address string
	Client  *http.Client
}

func NewFeedly

func NewFeedly(address string) *Feedly

func (*Feedly) Subscribers

func (f *Feedly) Subscribers() (string, error)

type FeedlyResponse

type FeedlyResponse struct {
	Results []map[string]any `json:"results"`
}

type Git

type Git struct {
	Path string
}

func NewGit

func NewGit(path string) *Git

func (*Git) Branches

func (g *Git) Branches() ([][]string, error)

type Github

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

Github structure connects to the Github API.

func NewGithubClient

func NewGithubClient(token string, owner string, repoName string) (*Github, error)

GithubClient to fetch Github related data.

func (*Github) CountCommits

func (g *Github) CountCommits(
	repository string,
	scope string,
	startWeek int64,
	endWeek int64,
	startDate time.Time,
) ([]string, []int, error)

CountCommits of a repository overtime.

func (*Github) CountStars

func (g *Github) CountStars(repository string, startDate, endDate time.Time) (dim []string, val []int, err error)

CountStars of a repository overtime. Only on a daily basis for now.

func (*Github) LastWorkflowRun

func (g *Github) LastWorkflowRun(repository string, branch string) (string, error)

LastWorkflowRun of the Github Actions of a repository, like "success - CI #12 on main".

func (*Github) ListBranches

func (g *Github) ListBranches(repository string, limit int) ([][]string, error)

ListBranches of a repository.

func (*Github) ListIssues

func (g *Github) ListIssues(repository string, limit int) ([][]string, error)

ListIssues of a repository.

func (*Github) ListPullRequests

func (g *Github) ListPullRequests(repository string, limit int) ([][]string, error)

ListPullRequests of a repository.

func (*Github) ListRepo

func (g *Github) ListRepo(limit int, order string, metrics []string) ([][]string, error)

ListRepo of a Github account.

func (*Github) TotalOpenIssues

func (g *Github) TotalOpenIssues(repository string) (int, error)

TotalOpenIssues of a repository overtime.

func (*Github) TotalStars

func (g *Github) TotalStars(repository string) (int, error)

TotalStars of a repository.

func (*Github) TotalWatchers

func (g *Github) TotalWatchers(repository string) (int, error)

TotalWatchers of a repository overtime.

func (*Github) Views

func (g *Github) Views(repository string, days int) ([]string, []int, error)

Views on a github repository the last 7 days.

func (*Github) WorkflowRuns

func (g *Github) WorkflowRuns(repository string, branch string, limit int) ([][]string, error)

WorkflowRuns of the Github Actions of a repository, from the most recent, with a header.

type Host

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

Host runs the commands of the widgets, on the local host or through SSH.

func NewHost

func NewHost(username, addr, knownHosts string) (*Host, error)

NewHost connects to a remote host through SSH. The username and address "localhost" are the local host.

func (*Host) Runner

func (s *Host) Runner(command string) (string, error)

Runner runs a command on the remote server through SSH, or on the local host.

type SearchConsole

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

SearchConsole connect to the Google Search Console API.

func NewSearchConsoleClient

func NewSearchConsoleClient(keyfile string) (*SearchConsole, error)

NewSearchConsoleClient create a SearchConsole.

func (*SearchConsole) Table

func (w *SearchConsole) Table(
	startDate string,
	endDate string,
	limit int64,
	address string,
	dimension string,
	filters string,
) ([]SearchConsoleResponse, error)

Table of Google Search Console with a dimension and its values.

type SearchConsoleResponse

type SearchConsoleResponse struct {
	Dimension   string
	Clicks      float64
	Impressions float64
	Ctr         float64
	Position    float64
}

SearchConsoleResponse returned after requesting the API.

Jump to

Keyboard shortcuts

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