clientlib

package
v0.0.0-...-794a95f Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package clientlib provides utility functions to help with downloading client libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadURL

func DownloadURL(language, name, version string) (string, error)

DownloadURL returns the URL of the client library archive for the given language and service name/version. If an unknown language is provided, an error is returned.

func DownloadUnzip

func DownloadUnzip(url, dst string, buf Buffer) error

DownloadUnzip downloads and unzips client libraries.

`url` is assumed to be a zip archive containing things we want. `dst` is the directory that the content should be unzipped to. `buf` is used to as buffer space for unzipping.

If non-nil error is returned, there is no guarantee as to which files, if any, were written to `dst`.

DownloadUnzip is safe to be called in parallel. However, races can happen if two invocations want to write to the same files.

func DownloadUnzipIfMissing

func DownloadUnzipIfMissing(libs []Lib, dstDir string) error

DownloadUnzipIfMissing downloads libraries `libs` into directory `dst` if the libraries don't already exist.

Library `l` is considered to "exist" if directory "dstDir/{l.Name}" exists. If the library doesn't yet exist, the content of l.URL is unzipped into "dstDir/{l.Name}". TODO(vchudnov-g): Add version

func LandingPage

func LandingPage(language, name, version string) (string, error)

LandingPage returns the client library landing page for the given language and service name/version. If an unknown language is provided, an error is returned.

Types

type Buffer

type Buffer interface {
	io.Writer

	// FinishWrite is called after all writes and before any read, giving Buffer a chance to prepare
	// for reading. It should return the amount of data it has read, in bytes,
	// and any errors encountered.
	FinishWrite() (int64, error)

	io.ReaderAt
}

Buffer is the interface to provide DownloadUnzip with buffer space.

type Lib

type Lib struct {
	Name, URL string
}

Lib represents a downloadable client library.

type MemBuffer

type MemBuffer struct {
	bytes.Buffer
	*bytes.Reader
}

MemBuffer implements Buffer in-memory.

func (*MemBuffer) FinishWrite

func (b *MemBuffer) FinishWrite() (int64, error)

FinishWrite prepares b for reading. Always return nil error.

func (*MemBuffer) Reset

func (b *MemBuffer) Reset()

Reset resets MemBuffer, allowing the allocation to be reused.

Jump to

Keyboard shortcuts

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