gog

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthError

func IsAuthError(err error) bool

IsAuthError checks if the error is a gog authentication error (exit status 4).

Types

type File

type File struct {
	ID           string   `json:"id"`
	Name         string   `json:"name"`
	MimeType     string   `json:"mimeType"`
	Parents      []string `json:"parents"`
	ModifiedTime string   `json:"modifiedTime"`
	Size         int64    `json:"size,string,omitempty"`
	WebViewLink  string   `json:"webViewLink"`
}

File represents a simplified Google Drive file structure returned by gog.

type Gog

type Gog struct {
	Account string
}

Gog is a wrapper for the gog CLI.

func New

func New(account string) *Gog

New creates a new Gog wrapper instance.

func (*Gog) AuthList

func (g *Gog) AuthList(ctx context.Context) ([]string, error)

AuthList returns a list of authenticated Google accounts from gog that have the required scopes (drive and sheets).

func (*Gog) DocsCat

func (g *Gog) DocsCat(ctx context.Context, fileID string) (string, error)

DocsCat returns the content of a Google Doc as Markdown.

func (*Gog) DriveDownload

func (g *Gog) DriveDownload(ctx context.Context, fileID string, format string) ([]byte, error)

DriveDownload downloads a file from Google Drive and returns its content as bytes. WARNING: This function pipes binary content through stdout and is only safe for text-based export formats (e.g., format="txt", format="md"). For binary formats (docx, xlsx, pptx, pdf), use DriveDownloadToFile instead to avoid stdout corruption of binary content.

func (*Gog) DriveDownloadToFile

func (g *Gog) DriveDownloadToFile(ctx context.Context, fileID string, format string, outputPath string) error

DriveDownloadToFile downloads a file from Google Drive to a specific path.

func (*Gog) DriveLs

func (g *Gog) DriveLs(ctx context.Context, parentID string) ([]File, error)

DriveLs lists files in a specific folder.

func (*Gog) DriveMkdir

func (g *Gog) DriveMkdir(ctx context.Context, name string, parentID string) (string, error)

DriveMkdir creates a folder in Google Drive. It returns the ID of the created folder.

func (*Gog) DriveSearch

func (g *Gog) DriveSearch(ctx context.Context, query string) ([]File, error)

DriveSearch searches for files matching a query.

func (*Gog) SheetsAppend

func (g *Gog) SheetsAppend(ctx context.Context, sheetID string, cellRange string, values [][]string) error

SheetsAppend appends rows to a range in a Google Sheet using JSON values.

func (*Gog) SheetsCreate

func (g *Gog) SheetsCreate(ctx context.Context, title string, parentID string) (string, error)

SheetsCreate creates a new Google Sheet. It returns the spreadsheet ID of the created sheet.

func (*Gog) SheetsGet

func (g *Gog) SheetsGet(ctx context.Context, sheetID string) (string, error)

SheetsGet returns the content of a Google Sheet as a Markdown table.

func (*Gog) SheetsGetValues

func (g *Gog) SheetsGetValues(ctx context.Context, sheetID string, cellRange string) ([][]string, error)

SheetsGetValues returns values from a range in a Google Sheet as [][]string.

func (*Gog) SheetsMetadata

func (g *Gog) SheetsMetadata(ctx context.Context, sheetID string) (*SpreadsheetMetadata, error)

SheetsMetadata returns metadata for a Google Spreadsheet.

func (*Gog) SheetsUpdate

func (g *Gog) SheetsUpdate(ctx context.Context, sheetID string, cellRange string, values [][]string) error

SheetsUpdate updates a range in a Google Sheet using JSON values.

type Sheet

type Sheet struct {
	Properties SheetProperties `json:"properties"`
}

Sheet represents a tab in a Google Spreadsheet.

type SheetProperties

type SheetProperties struct {
	Title string `json:"title"`
	Index int    `json:"index"`
}

SheetProperties represents properties of a Google Sheet tab.

type SpreadsheetMetadata

type SpreadsheetMetadata struct {
	ID     string  `json:"spreadsheetId"`
	Sheets []Sheet `json:"sheets"`
}

SpreadsheetMetadata represents metadata for a Google Spreadsheet.

Jump to

Keyboard shortcuts

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