viagh

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 13 Imported by: 0

README

viagh build Go Reference

:octocat: viagh.NewHTTPClient returns a *http.Client that makes API requests via the gh command.

Why viagh?

When writing a GitHub CLI extension, the extension needs to exec the gh command internally to execute API requests with credentials.

By using http.Client that executes API requests via the gh command, you can use existing useful packages such as go-github without modification.

Usage

package main

import (
	"context"
	"fmt"

	"github.com/google/go-github/v39/github"
	"github.com/k1LoW/viagh"
)

func main() {
	ctx := context.Background()
	client, _ := viagh.NewHTTPClient()
	gh := github.NewClient(client)

	u, _, _ := gh.Users.Get(ctx, "k1LoW")
	fmt.Println(u.GetLogin())
}

Documentation

Overview

Example
ctx := context.Background()
client, _ := NewHTTPClient()
gh := github.NewClient(client)

u, _, _ := gh.Users.Get(ctx, testOwner)
fmt.Println(u.GetLogin())
Output:

k1LoW

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient() (*http.Client, error)

NewHTTPClient returns a *http.Client that makes API requests via the `gh` command

Types

This section is empty.

Jump to

Keyboard shortcuts

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