[go-nuts] Help understanding slices, variable arguments, and passing slices to functions

2023-09-25 Thread Andrew Pillar
I have some code whereby I am iterating over some data, putting that data into a buffer slice defined outside the loop, then passing the contents of that buffer slice to a function which returns a struct containing that data. See the playground link as a stripped down demonstration of what I'm actu

[go-nuts] req an HTTP scripting language

2022-06-14 Thread Andrew Pillar
Hi all, req is an HTTP scripting language that I've been working on. The intention behind it is to provide a high-level language for quickly scraping data off of web APIs or web pages. Just recently, v1.1.0 has been released which adds support for working with cookies. Feel free to check it out i

Re: [go-nuts] Structured configuration in Go

2022-04-10 Thread Andrew Pillar
> I think there are two big advantages to making your application > consume either plain JSON or YAML configs: > 1. Everyone is familiar with them > 2. You can use a more advanced tool like cue or jsonnet to generate > them I can see why people would prefer JSON, and I think it's fine for storing

Re: [go-nuts] Structured configuration in Go

2022-04-09 Thread Andrew Pillar
> Out of interest, have you come across CUE? > I have heard of it, but not explored it in depth. At a glance it seems too heavyweight for what I wanted. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop rec

[go-nuts] Structured configuration in Go

2022-04-09 Thread Andrew Pillar
An article I wrote about a new configuration library I developed in Go for working with structured configuration. Article: https://andrewpillar.com/programming/2022/04/09/structured-configuration-in-go/ Repo: https://github.com/andrewpillar/config -- You received this message because you are sub

Re: [go-nuts] Golang library for - ORM & Schema Migration

2019-10-01 Thread Andrew Pillar
I created a simple migration tool called mgrt [1], which operates on pure SQL scripts that are defined by the user. It has support for MySQL, SQLite and PostgreSQL. Give it a try if you're looking for a simple migration tool that just uses plain SQL under the hood. It's written in Go, so building i

Re: [go-nuts] Re: Can’t get latest package version with modules

2019-10-01 Thread Andrew Pillar
>Thank you all. For schema migration i am looking for similar tool like flyway. I created a simple migration tool called mgrt [1], which operates on pure SQL scripts that are defined by the user. It has support for MySQL, SQLite and PostgreSQL. Give it a try if you're looking for a simple migratio

Re: [go-nuts] How to use .toml file to parse IP address and port to http server

2019-09-29 Thread Andrew Pillar
Use net.JoinHostPort to concatenate the values you have in the struct and pass the to http.Server struct. if _, err := toml.Decode("config.toml", &conf); err != nil { // handle error } addr, err := net.JoinHostPort(conf.Address, conf.PORT) if err != nil { // handle error } s

Re: [go-nuts] Dependency injection in gorillamux handlers

2019-09-23 Thread Andrew Pillar
Why don't you use context.WithValue(r.Context(), , ) for passing the injected values you want to your HTTP handlers. Then defer the logic for retrieving whatever you want for that handler to a middleware function. -- You received this message because you are subscribed to the Google Groups "gola

Re: [go-nuts] listen port auto allocation questions

2019-07-13 Thread Andrew Pillar
> How can i'm avoid such errors and not specify ports by hand? Perhaps you could use some kind of central store for storing the most recently used port? Simply take that port from the store, increment it, and place it back into the store for the next micro-service to use. I think etcd [1], may be

[go-nuts] Some thoughts on query building in Go

2019-07-13 Thread Andrew Pillar
I put together a blog post exploring some of the approaches that could be taken for idiomatic query building in Go. The Tl;DR of it is this: First class functions are an idiomatic way of doing SQL query building in Go. Check out the repository containing some example code I wrote testing this out:

Re: [go-nuts] Does the code have any concurrent problem?

2019-07-05 Thread Andrew Pillar
Have you tried building with the -race flag? go build - race This should help you figure out any data race conditions that may occur. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails fro

Re: [go-nuts] Re: Best ORM for Golang and their framework like Revel and Martini

2019-06-09 Thread Andrew Pillar
I made a comment about this on an HN thread about ORMs in Go. > Personally I think an active record style ORM for Go like gorm is a poor fit for a language that doesn't come across as inherently OOP. Going through some of the documentation for gorm, it seems to rely heavily on method chaining

Re: [go-nuts] Re: Best ORM for Golang and their framework like Revel and Martini

2019-06-09 Thread Andrew Pillar
I made a comment about a similar topic on an HN thread, about ActiveRecord style ORMs in Go. > Personally I think an active record style ORM for Go like gorm is a > poor fit for a language that doesn't come across as inherently OOP. > Going through some of the documentation for gorm, it seems to