Skip to content

haquenafeem/gopunch

Repository files navigation

gopunch

GoPunch workflow Go Reference Go Report Card

gopunch is a simple golang package to make http calls.

Install

go get -u github.com/haquenafeem/gopunch

Features

  • Easy To Use
  • Use Own Unmarshal Logic
  • Create With/Without Timer
  • Default JSON Oriented
  • Request/Respose Modification
  • Examples To Get You Started
  • All Tests/Examples Based On JSON Place Holder
  • Tests Passing

Usage

package main

import (
	"context"
	"fmt"

	"github.com/haquenafeem/gopunch"
)

type Todo struct {
	UserID    int    `json:"userId"`
	ID        int    `json:"id"`
	Title     string `json:"title"`
	Completed bool   `json:"completed"`
}

func main() {
	client := gopunch.New("https://jsonplaceholder.typicode.com")
	ctx := context.Background()

	var todos []Todo
	opt := gopunch.WithHeaders(map[string]string{
		"Content-Type": "application/json",
	})

	err := client.GetUnmarshal(ctx, "/todos", &todos, opt)
	if err != nil {
		panic(err)
	}

	fmt.Println(todos)
}

Complete Example Here