Warning: Undefined array key "rss_show_deleted" in /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php on line 86

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 53

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 55

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 56

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 33
wi12.unix7.org - go https://w12.unix7.org/ Wed, 05 Aug 2026 03:48:34 +0000 FeedCreator 1.8 https://w12.unix7.org/_media/wiki/dokuwiki.svg wi12.unix7.org https://w12.unix7.org/ accountdb.go https://w12.unix7.org/go/accounts go accountdb.go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package accountdb import ( "strings" "fmt" "io/ioutil" "path/filepath" "math/rand" "errors" "os" "github.com/GehirnInc/crypt" _ "github.com/GehirnInc/crypt/sha256_crypt" ) type Account struct { Username string Digest string } type AccountDB struct { FileName string } const ( DigestMinLen = 56 UsernameMinLen = 4 PasswordMinLen = 4 ) const letters = … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Apollo GrapQL web socket reader & parser https://w12.unix7.org/go/apollo Apollo GrapQL web socket reader & parser /* * Copyright 2020 Oleg Borodin <borodin@unix7.org> * */ package mdcore import ( "context" "encoding/json" "net/http" "net/url" "sync" "app/pgquery" "app/pmlog" "github.com/gorilla/websocket" ) const ( gPayloadMessageKey string = "message" gwsConnectionInit string = "connection_init" gwsConnectionError string = "conn_err" gwsStart string = "start" gwsStop … anonymous@undisclosed.example.com (Anonymous) Sun, 18 Dec 2022 23:29:14 +0000 Mini application pattern https://w12.unix7.org/go/app-sample go Mini application pattern goweb.go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "net/http" "log" "errors" "strings" "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/cookie" "github.com/gin-gonic/gin" "fmt" "os" "time" "github.com/dustin/go-humanize" "github.com/jmoiron/sqlx" _ "github.com/jackc/pgx/v4/stdlib" "goweb/accounts" ) type DbInfo struct { DatName string … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Go threads & channels sample https://w12.unix7.org/go/channels go Go threads & channels sample /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "time" ) func sender1(c chan string) { for i := 0; ; i++ { c <- "message 1" time.Sleep(time.Millisecond * 100) } } func sender2(c chan string) { for i := 0; ; i++ { c <- "message 2" time.Sleep(time.Millisecond * 200) } } func receiver(c1 chan string, c2 chan string) { for { select { case… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 https://w12.unix7.org/go/context go package main import ( "context" "fmt" "time" "sync" ) func loop(wg *sync.WaitGroup, ctx context.Context) { wg.Add(1) defer wg.Done() //<-ctx.Done() //fmt.Println("done") //return for { select { case <- ctx.Done(): fmt.Println("done") return default: } time.Sleep(1 * time.Second) fmt.Println(time.Now().UTC()) } } func main() { ctx, cancel := context.Wi… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Cron Record Expander https://w12.unix7.org/go/cron-record-expander go Cron Record Expander /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "regexp" "strings" "strconv" ) func main() { max := 23 field := expander("1-2,5-6,,*//5,,", max) for i := 0; i < max; i++ { if field[i] { fmt.Print(i, " ") } } fmt.Println("") } /* Expand comma-separated list records like * /N, N-M,* */ func expander(items string, max int) map[int]bool { items = strings… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 https://w12.unix7.org/go/custom-types go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "encoding/json" "errors" ) type Bool bool func (this Bool) MarshalJSON() ([]byte, error) { json, err := json.Marshal(bool(this)) return json, err } func (this *Bool) UnmarshalJSON(data []byte) error { var err error var ref interface{} err = json.Unmarshal(data, &ref) if err != nil { *this = false return nil } switch v := ref.(type) {… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Simple filestore on Golang https://w12.unix7.org/go/filestore go Simple filestore on Golang Now is very ditry but work =) /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "github.com/gin-gonic/gin" //"github.com/sevlyar/go-daemon" "net/http" "fmt" "log" "path/filepath" "os" "path" "time" "io" "mime/multipart" ) func main() { context := &daemon.Context{ PidFileName: "gin.pid", PidFilePerm: 0644, LogFileName: "gin.log", LogFilePerm: 064… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Gin with session https://w12.unix7.org/go/gin-session-sample go Gin with session /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "net/http" "log" "errors" "strings" "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/cookie" "github.com/gin-gonic/gin" ) func CheckAuthMiddleware(context *gin.Context) { session := sessions.Default(context) username := session.Get("username") if username == nil { context.Redirect(http.StatusMovedPermanently, "/login") … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Go, Gin and SQLx https://w12.unix7.org/go/gin-sql-sample go Go, Gin and SQLx /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "net/http" "github.com/gin-gonic/gin" "fmt" "os" "time" "log" "github.com/jmoiron/sqlx" _ "github.com/jackc/pgx/v4/stdlib" ) type DbInfo struct { DatName string `db:"datname" json:"datname"` Size int64 `db:"size" json:"size"` Owner string `db:"owner" json:"owner"` NumBackends int `db:"numbackends" json:"numbacken… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 SQL Calendar periods generator https://w12.unix7.org/go/goment go SQL Calendar periods generator And goment sample. /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "time" //"encoding/json" "regexp" "github.com/nleeper/goment" ) const ( startYear int = 2019 endYear int = 2025 ) type Day struct { Id int `json:"id" db:"id"` Number int `json:"number" db:"number"` Date string `json:"date" db:"date"` … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 GraphQL in Golang sample https://w12.unix7.org/go/graphql go GraphQL in Golang sample Server /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "github.com/gin-gonic/gin" "goql/controller" ) func main() { gin.DisableConsoleColor() gin.SetMode(gin.ReleaseMode) router := gin.Default() controller := controller.New() router.GET("/hello", controller.Hello) router.POST("/query", controller.GraphQL) router.Run() } anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Binary coding-decoding at reflect https://w12.unix7.org/go/icoder Binary coding-decoding at reflect As research goos: linux goarch: amd64 pkg: fsm/finder cpu: Intel(R) Core(TM) i5-4300U CPU @ 1.90GHz BenchmarkBinWrite-4 13289688 185.1 ns/op 128 B/op 4 allocs/op BenchmarkAtoi-4 53319615 44.95 ns/op 7 B/op 0 allocs/op BenchmarkEncoder-4 40339908 57.88 ns/op 15 B/op 1 allocs/op BenchmarkEncoderHex-4 21469190 118.1 ns/op 31 B/op 2 allocs/op PASS ok fsm/fin… anonymous@undisclosed.example.com (Anonymous) Sun, 18 Dec 2022 10:46:31 +0000 json2path https://w12.unix7.org/go/jpath go json2path example1 /* * Copyright: 2017 Oleg Borodin <onborodin@gmail.com> */ package main import ( "encoding/json" "fmt" "log" "strings" "io" "path" ) func Decoder(data string) (map[string]interface{}, error) { var err error jpath := "/" keymap := make(map[string]interface{}) decoder := json.NewDecoder(strings.NewReader(data)) _, err = decoder.Token() if err != nil { return keymap, err } for { key, err :=… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 JSON schema generator https://w12.unix7.org/go/jschemagen JSON schema generator package main import ( "fmt" "reflect" "encoding/json" ) type Func struct { Method string `json:"method" descr:"Method name"` Params struct { Address string `json:"address" descr:"Target address"` Count string `json:"count" descr:"Count of retrains"` ReqNum int `json:"reqNum"` } `json:"params"` } /* JSON Schema Generator */ func Reflector(valu… anonymous@undisclosed.example.com (Anonymous) Wed, 07 Dec 2022 22:03:09 +0000 JSON Schema Generator https://w12.unix7.org/go/json-schema-gen go json JSON Schema Generator /* * Copyright 2020 Oleg Borodin <borodin@unix7.org> */ package main import ( "fmt" "reflect" "encoding/json" ) type Func struct { Method string `json:"method" descr:"Method name"` Params struct { Address string `json:"address" descr:"Target address"` Count string `json:"count" descr:"Count of retrains"` ReqNum int `json:"reqNum"` } `json:"params"` } /* JSON Schema Genera… anonymous@undisclosed.example.com (Anonymous) Mon, 18 Jul 2022 07:25:26 +0000 https://w12.unix7.org/go/jwt go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "bytes" //"crypto/rand" //"crypto/rsa" "encoding/json" "fmt" "time" "github.com/lestrrat-go/jwx/jwa" "github.com/lestrrat-go/jwx/jwt" //"github.com/lestrrat-go/jwx/jws" ) func main() { token1 := jwt.New() token1.Set(jwt.IssuerKey, "Issuer") token1.Set(jwt.SubjectKey, "SubjectKey") token1.Set(jwt.AudienceKey, "AudienceKey") token1.Set(jwt.IssuedAtKey, time.Now()) … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Structure encoder to key-value https://w12.unix7.org/go/kvenc Structure encoder to key-value /* * Copyright Oleg Borodin <borodin@unix7.org> * */ package main import ( "encoding/json" "fmt" "reflect" ) const tagName string = "mytag" const idTagName string = "id" type User struct { Id int `mytag:"id" json:"id"` Name string `mytag:"name" json:"name"` Pass string `mytag:"pass" json:"pass"` Phone string `mytag:"pnum" json:"pnum"` } func encoder(prefix string, s interfac… anonymous@undisclosed.example.com (Anonymous) Mon, 03 Jan 2022 23:27:54 +0000 Very simple rate limiter https://w12.unix7.org/go/limiter go Very simple rate limiter /* * Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "time" ) func main() { limiter := NewLimiter(1, 1) timer := time.NewTicker(1 * time.Millisecond) for _ = range timer.C { timestamp := time.Now().UnixNano() value, passed := limiter.Pass(timestamp) if passed { fmt.Println(value) } } } type Limiter struct { timestamp int64 period float64 rate … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Golang Gin service sample https://w12.unix7.org/go/listdir go Golang Gin service sample /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "github.com/gin-gonic/gin" "net/http" "fmt" "log" "path/filepath" "os" "path" "time" ) type File struct { Name string `json:"name"` Size int64 `json:"size"` } func listDir (dir string, glob string) []File { files, err := filepath.Glob(path.Join(dir, glob)) if err != nil { log.Fatal(err) } list := []File{} … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Simple HTTP file server https://w12.unix7.org/go/microstore go Simple HTTP file server До этого я никогда не писал код на Go lang. Это первый код, ~300 строк. Написание этой пары клиент-сервер с обучением заняло ~10 часов. anonymous@undisclosed.example.com (Anonymous) Sat, 05 Feb 2022 08:21:42 +0000 Go OOP sample https://w12.unix7.org/go/object go Go OOP sample /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "objgo/calc" ) func main() { i := calc.New() i.Add("some", 10) i.Add("bare", 10) i.Add("foo", 20) i.Delete("foo") i.Print() fmt.Println("OK") } anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Binary protocol example, adaptation for Golang https://w12.unix7.org/go/packet go net Binary protocol example, adaptation for Golang As example like Message protocol prototype Sender order: * Prepare payload * Get payload size * Prepare and pack header * Send header and * Send payload (by part or all) * ... Receiver order: * Receive and unpack header anonymous@undisclosed.example.com (Anonymous) Fri, 03 Dec 2021 07:28:08 +0000 Password-file like account and authentication module https://w12.unix7.org/go/password-module go Password-file like account and authentication module ... for mini-services. Accounts always read/write from/to file “by design” =). /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package accounts import ( "math/rand" "fmt" "os" "bufio" "regexp" "errors" "github.com/GehirnInc/crypt" _ "github.com/GehirnInc/crypt/sha256_crypt" ) type AccountDB struct { FileName string } type Account struct{ Name string Digest string } var pa… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 PostgresQL LISTEN/NOTIFY + Golang sample https://w12.unix7.org/go/pg-notes go PostgresQL LISTEN/NOTIFY + Golang sample /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "context" "fmt" "log" "time" "os" "errors" "github.com/jmoiron/sqlx" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" ) type Server struct { Dbp *sqlx.DB Pool *pgxpool.Pool } const ( DbUsername string = "e2api" DbPassword string = "e2api" DbHostname string = "loca… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Golang and SQL sample https://w12.unix7.org/go/pgx-sample go Golang and SQL sample /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "os" "time" "database/sql" _ "github.com/jackc/pgx/v4/stdlib" ) func main() { db, err := sql.Open("pgx", "postgres://pgsql@localhost/postgres?sslmode=disable") if err != nil { fmt.Printf("error: %s\n", err) os.Exit(1) } defer db.Close() err = db.Ping() if err != nil { fmt.Printf("error: %s\n", err) … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Simple object constructor https://w12.unix7.org/go/picker.go Simple object constructor This is examples of re-construct object from object description. with embedded JS virtial machine /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "encoding/json" "fmt" "github.com/dop251/goja" ) const ( marhallIndent1 string = "" marhallIndent2 string = " " ) func main() { // make & export json engine description engineDesc := makeEngineDesc() fmt.Println("export descrition:", string(eng… anonymous@undisclosed.example.com (Anonymous) Tue, 06 Dec 2022 08:11:16 +0000 https://w12.unix7.org/go/pingpong go package main import ( "fmt" "time" ) func pinger0(c chan string) { for i := 0; ; i++ { c <- "ping0" } } func printer(c chan string) { for { msg := <- c fmt.Println(msg) time.Sleep(time.Second * 1) } } func pinger1(c chan string) { for i := 0; ; i++ { c <- "ping1" } } func main() { var c chan string = make(chan string, 5) go pinger0(c) go pinger1(c) go printer(c) var input string fmt.Sc… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 https://w12.unix7.org/go/pingpong2 go package main import ( "fmt" "time" ) func pinger0(c chan string) { for i := 0; ; i++ { c <- "ping0" } } func pinger1(c chan string) { for i := 0; ; i++ { c <- "ping1" } } func printer(c0 chan string, c1 chan string) { for { select { case msg0 := <- c0: fmt.Println("Message 0", msg0) case msg1 := <- c1: fmt.Println("Message 1", msg1) case <- time.After(time.Second): fmt.Pr… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Max RC copter loading https://w12.unix7.org/go/rcmax go rc octave Max RC copter loading package main import ( "fmt" "math" ) func Grad2Rad(value float64) float64 { return (math.Pi / 180.0) * value } func main() { const chassisSpeed float64 = 50 // kmh const chassisAngle float64 = 30 // grad const thrustReductionFactor float64 = 0.35 const chassisWeight float64 = 300 // g const initialBatteryWeight float64 = 200 // g const initialBa… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Output https://w12.unix7.org/go/reactor go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> * */ package main import ( "fmt" "time" "math/rand" ) type Message struct { Id int64 Subject string Body string } type Report struct { WorkerId int64 MessageId int64 Err error } type Worker struct { Id int64 Mailbox chan Message Reports chan Report } func NewWorker(id int64, reports chan Report) *Worker { mailbox := make(chan Message, 10) … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 strings https://w12.unix7.org/go/reader strings * type Builder * func (b *Builder) Cap() int * func (b *Builder) Grow(n int) * func (b *Builder) Len() int * func (b *Builder) Reset() * func (b *Builder) String() string * func (b *Builder) Write(p []byte) (int, error) anonymous@undisclosed.example.com (Anonymous) Tue, 30 Nov 2021 17:19:15 +0000 out https://w12.unix7.org/go/ref // // $Id$ // package main import ( "fmt" ) func ref1() []byte { a := make([]byte, 0) a = append(a, []byte("qwerty")...) fmt.Printf("%p\n", a) return a } func ref2(a []byte) { fmt.Printf("%p\n", a) } func main() { a := ref1() fmt.Printf("%p\n", a) ref2(a) } //EOF anonymous@undisclosed.example.com (Anonymous) Thu, 16 Dec 2021 19:20:52 +0000 Response example https://w12.unix7.org/go/resp-sample Response example // // $Id$ // package main import ( "encoding/json" "fmt" ) type Response struct { Error bool `json:"error"` Message string `json:"message,omitempty"` Result interface{} `json:"result,omitempty"` } func main() { var resp Response resp.Message = "" jsonBytes, _ := json.Marshal(resp) fmt.Println(string(jsonBytes)) } //EOF anonymous@undisclosed.example.com (Anonymous) Tue, 14 Dec 2021 13:58:50 +0000 Serve example https://w12.unix7.org/go/sema2 go thread async Serve example /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "math/rand" "time" "sync" ) type Server struct { semafor chan bool wg *sync.WaitGroup } func (this *Server) Serve(message string) { this.wg.Add(1) defer this.wg.Done() select { case this.semafor <- true: fmt.Println("#serve", message) break case <- time.After(1 * time.Second): … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Spooler template https://w12.unix7.org/go/spooler go Spooler template /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "fmt" "time" "math/rand" ) const ( maxThreads = 5 ) type Spool struct { Signals chan string } func (this Spool) Push(tag string, message string) { fmt.Println("push:", tag) // Dummy } func (this Spool) Pull() { fmt.Println("pull") // Dummy } func (this Spool) Loop() { var threads int = 0 var generation int = 0 // For easy id presentation for { list := []int{ 1, 2, 3, … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 SQL to JSON https://w12.unix7.org/go/sql2json go SQL to JSON /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "encoding/json" "fmt" "os" "github.com/jmoiron/sqlx" _ "github.com/jackc/pgx/v4/stdlib" ) func main() { db, err := sqlx.Open("pgx", "postgres://pgsql@localhost/postgres?sslmode=disable") if err != nil { fmt.Printf("error: %s\n", err) os.Exit(1) } defer db.Close() err = db.Ping() if err != nil { fmt.Printf("error: %s\n", … anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 Simple example of TCP server https://w12.unix7.org/go/tcpserv go net Simple example of TCP server * On pure C * Example of bin protocol on pure C server package main import ( "net" "fmt" "bufio" "time" "os" ) const ( delim byte = 0x0A ) func main() { fmt.Println("") listener, err:= net.Listen("tcp", ":8081") if err != nil { fmt.Println("#listen err:", err) os.Exit(1) } for { conn, err := listener.Accept() if err != nil { fmt.Println("#accept err:", err) … anonymous@undisclosed.example.com (Anonymous) Wed, 01 Dec 2021 17:40:14 +0000 https://w12.unix7.org/go/unm go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "encoding/json" //"errors" "fmt" "reflect" ) type InvoicePayload struct { InvoiceUID string `json:"invoiceUID"` InvoiceRef string `json:"invoiceRef"` } type Invoice struct { Payload []InvoicePayload } func (this Invoice) MarshalJSON() ([]byte, error) { json, err := json.Marshal(this.Payload) return json, err } func (this *Invoice) UnmarshalJSON(data []by… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000 https://w12.unix7.org/go/unm2 go /* * Author, Copyright: Oleg Borodin <onborodin@gmail.com> */ package main import ( "encoding/json" "fmt" ) type Request struct { Invoices Invoices `json:"invoice"` } type Invoice struct { InvoiceUID string `json:"invoiceUID"` } type Invoices struct { Payload []Invoice } func (this Invoices) MarshalJSON() ([]byte, error) { json, err := json.Marshal(this.Payload) return json, err } func (this *Invoices) UnmarshalJSON(data []byte) error { this.Paylo… anonymous@undisclosed.example.com (Anonymous) Sat, 27 Nov 2021 13:26:11 +0000