Skip to content
/ job Public

A package to schedule both recurring and one time job.

License

Notifications You must be signed in to change notification settings

shaswata56/job

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

job

A Go package to schedule both recurring and one time job.

Example Usage

package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
	"time"

	"github.com/shaswata56/job"
)

func GetWeatherNow(args ...any) {
	city := ""
	if str, ok := args[0].(string); ok {
		city = str
	}
	url := "https://wttr.in/" + strings.ToLower(city) + "?format=2"
	resp, err := http.Get(url)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Print("Dhaka: " + string(body))
}

func main() {
	myArgs := []any{}
	myArgs = append(myArgs, "Dhaka")
	myJob := job.Job{
		Fn:   GetWeatherNow,
		Args: myArgs,
	}
	myJob.ScheduleRecurring(time.Second * 2)
	time.Sleep(time.Minute)
}

Import in your project by go-get

go get github.com/shaswata56/job

About

A package to schedule both recurring and one time job.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages