From 96e5318b620d617873d21933a6d6e143e7acd2b1 Mon Sep 17 00:00:00 2001 From: Thanh Nguyen Date: Wed, 21 Feb 2024 23:25:11 +1100 Subject: [PATCH] CI: update module structure --- gjrc/gjrc.go | 49 ---------------------------------------------- gjrc/module.go | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 49 deletions(-) create mode 100644 gjrc/module.go diff --git a/gjrc/gjrc.go b/gjrc/gjrc.go index bca108f..8c17041 100644 --- a/gjrc/gjrc.go +++ b/gjrc/gjrc.go @@ -1,47 +1,3 @@ -/* -Package gjrc offers generic utilities to work with JSON-based RESTful API. - -Sample usage: - - package main - - import ( - "fmt" - - "github.com/btnguyen2k/consu/gjrc" - "github.com/btnguyen2k/consu/reddo" - ) - - func main() { - // // pre-build a http.Client - // httpClient := &http.Client{} - // client := NewGjrc(httpClient, 0) - - // or, a new http.Client is created with 10 seconds timeout - client := NewGjrc(nil, 10*time.Second) - - url := "https://httpbin.org/post" - resp := client.PostJson(url, map[string]interface{}{"key1": "value", "key2": 1, "key3": true}) - - val1, err := resp.GetValueAsType("json.key1", reddo.TypeString) - if err != nil { - panic(err) - } - fmt.Printf("%#v\n", val1) // output: "value" - - val2, err := resp.GetValueAsType("json.key2", reddo.TypeInt) - if err != nil { - panic(err) - } - fmt.Printf("%#v\n", val2) // output: 2 - - val3, err := resp.GetValueAsType("json.key3", reddo.TypeBool) - if err != nil { - panic(err) - } - fmt.Printf("%#v\n", val3) // output: true - } -*/ package gjrc import ( @@ -60,11 +16,6 @@ import ( "github.com/btnguyen2k/consu/semita" ) -const ( - // Version defines version number of this package - Version = "0.2.1" -) - // NewGjrc creates a new Gjrc object. // It reuses the http.Client if supplied (then timeout is ignored). Otherwise, a new client is created with the // specified timeout. diff --git a/gjrc/module.go b/gjrc/module.go new file mode 100644 index 0000000..5863c92 --- /dev/null +++ b/gjrc/module.go @@ -0,0 +1,53 @@ +/* +Package gjrc offers generic utilities to work with JSON-based RESTful API. + +Sample usage: + + package main + + import ( + "fmt" + + "github.com/btnguyen2k/consu/gjrc" + "github.com/btnguyen2k/consu/reddo" + ) + + func main() { + // // pre-build a http.Client + // httpClient := &http.Client{} + // client := NewGjrc(httpClient, 0) + + // or, a new http.Client is created with 10 seconds timeout + client := NewGjrc(nil, 10*time.Second) + + url := "https://httpbin.org/post" + resp := client.PostJson(url, map[string]interface{}{"key1": "value", "key2": 1, "key3": true}) + + val1, err := resp.GetValueAsType("json.key1", reddo.TypeString) + if err != nil { + panic(err) + } + fmt.Printf("%#v\n", val1) // output: "value" + + val2, err := resp.GetValueAsType("json.key2", reddo.TypeInt) + if err != nil { + panic(err) + } + fmt.Printf("%#v\n", val2) // output: 2 + + val3, err := resp.GetValueAsType("json.key3", reddo.TypeBool) + if err != nil { + panic(err) + } + fmt.Printf("%#v\n", val3) // output: true + } +*/ +package gjrc + +const ( + // Version defines version number of this package + Version = "0.2.1" +) + +// This file contains module's metadata only, which is package level documentation and module Version string. +// Module's code should go into other files.