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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址