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

gsc

package
v0.12.8 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthorizeURL

func AuthorizeURL(cfg *config.GSCConfig, state string) string

func ExchangeCode

func ExchangeCode(ctx context.Context, cfg *config.GSCConfig, code string) (*oauth2.Token, error)

func OAuthConfig

func OAuthConfig(cfg *config.GSCConfig) *oauth2.Config

Types

type AnalyticsRow

type AnalyticsRow struct {
	Date        string
	Query       string
	Page        string
	Country     string
	Device      string
	Clicks      int64
	Impressions int64
	CTR         float64
	Position    float64
}

type BatchCallback

type BatchCallback func(rows []AnalyticsRow, totalSoFar int) error

BatchCallback is called after each batch of rows is fetched from the API. rows contains the current batch; totalSoFar is the running total of rows fetched.

type Client

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

func NewClient

func NewClient(ctx context.Context, cfg *config.GSCConfig, token *oauth2.Token) (*Client, error)

func NewClientFromTokens

func NewClientFromTokens(ctx context.Context, cfg *config.GSCConfig, accessToken, refreshToken string, expiry time.Time) (*Client, *oauth2.Token, error)

NewClientFromTokens creates a client from raw token strings, refreshing if needed.

func (*Client) FetchSearchAnalytics

func (c *Client) FetchSearchAnalytics(ctx context.Context, propertyURL, startDate, endDate string, onBatch BatchCallback) (int, error)

func (*Client) FetchURLInspection

func (c *Client) FetchURLInspection(ctx context.Context, propertyURL string, urls []string) ([]InspectionRow, error)

func (*Client) ListProperties

func (c *Client) ListProperties(ctx context.Context) ([]Property, error)

func (*Client) ListSitemaps

func (c *Client) ListSitemaps(ctx context.Context, propertyURL string) ([]Sitemap, error)

type InspectionRow

type InspectionRow struct {
	URL               string
	Verdict           string
	CoverageState     string
	IndexingState     string
	RobotsTxtState    string
	LastCrawlTime     time.Time
	CrawledAs         string
	CanonicalURL      string
	IsGoogleCanonical bool
	MobileUsability   string
	RichResultsItems  int
}

type Property

type Property struct {
	SiteURL         string `json:"site_url"`
	PermissionLevel string `json:"permission_level"`
}

type Sitemap

type Sitemap struct {
	Path      string           `json:"path"`
	Type      string           `json:"type"`
	IsPending bool             `json:"is_pending"`
	Warnings  int64            `json:"warnings"`
	Errors    int64            `json:"errors"`
	Contents  []SitemapContent `json:"contents"`
}

type SitemapContent

type SitemapContent struct {
	Type      string `json:"type"`
	Submitted int64  `json:"submitted"`
	Indexed   int64  `json:"indexed"`
}

Jump to

Keyboard shortcuts

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