Skip to main content

Get the Reddit app

Scan this QR code to download the app now
Or check it out in the app stores
profgumby u/profgumby avatar

profgumby

u/profgumby

New
Open sort options
Change post view

r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

OpenAPI 3 documentation for API

profgumby
replied to sanylos

(maintainer here) although I appreciate you sharing oapi-codegen, we're primarily spec-first, not code-first, which may not quite work here. 

Kin-openapi does have the ability to parse types and produce OpenAPI schemas, which you could do as a first step, but not sure it'll cover all the cases



r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Go + gRPC + GORM + SQLite + GIN + Swagger

That's fair! I think there's (at least one) issue about it - my short answer is that if you split the spec into multiple files then use the "external refs" functionality can lead to being able to split things up a bit more manageable


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Sqlc: 2024 check in

profgumby
replied to markusrg

I think I'm gonna try and write my own - it's been best part of two years using it, but not at the scale Brandur and team are doing so, but I'm sure it'll still be interesting, even if it's just for me





r/apexlegends icon
A banner for the subreddit

Community run, developer supported subreddit dedicated to Apex Legends by Respawn Entertainment.


Members Online
r/apexlegends
A banner for the subreddit

Community run, developer supported subreddit dedicated to Apex Legends by Respawn Entertainment.


Members Online

Apex Legends: Altered Horizons

profgumby
replied to rcpotatosoup

what? Alternate reality includes literally everything conceivable, including Horizon being a fish, a robot, from a different set of parents, etc




r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

how to distribute a cli tool with go install?

profgumby
commented

Do you have a link to your repo?

Usually you can go install by pointing to where the package main is defined. I.e. https://gitlab.com/jamietanna/readme-generator has a main.go in the top-level of the repo, so can be installed with go install gitlab.com/jamietanna/readme-generator@latest

Or if it's in a subdirectory i.e. https://github.com/deepmap/oapi-codegen has ./cmd/oapi-codegen, then you'd install with go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest



r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Assigning structs

profgumby
replied to br1ghtsid3

Yup, helps find breaking / unintended side effects of changes, as well as making it sure that someone can import your code (ie as a module, from another module) because Go works based off source code (and you can't ie go:generate when pulling a module)



r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Manage environment variables in go

profgumby
commented

Surprised to not see https://github.com/kelseyhightower/envconfig here which is what I've used for production services whereas I'd use Viper for Cobra CLIs. 

Handles setting a struct (with/without struct tags) up with the env vars



r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Heu, what you guys prefer between deepmap/oapi-codegen and ogen-go/ogen

Oapi-codegen can now use opt-in Nullable types instead of pointers (which seems to have a slightly more comprehensive solution to Ogen's)

Disclaimer - I'm a maintainer of oapi-codegen


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How to extend code form openapi-generator

profgumby
commented

Oapi-codegen maintainer here - if you check out ie https://github.com/deepmap/oapi-codegen/tree/master/examples/petstore-expanded/chi you can see that we implement the interface separate to the generated code


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

Fuego, a Go 1.22 based framework that generates OpenAPI docs from source code

profgumby
replied to EwenQuim

Out of interest when you changed it did you get in touch with all the contributors? If not, you legally can't relicense unless you've got a CLA for all incoming contributions that reassign copyright



r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How do you represent a JSON field in Go that could be absent, `null` or have a value?

profgumby
replied to feketegy

So by "optional" I mean i.e. the following OpenAPI schema:

components:
  schemas:
    Pet:
      type: object
      properties:
        id:
          type: integer
          nullable: true
        name:
          type: string
          nullable: true
      required:
        - id

Or the following Go type:

type Pet struct {
    Id   int64
    Name *string
}

And how you'd be able to make it clear which of these are required fields, and which aren't expected to be sent in the request


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How do you represent a JSON field in Go that could be absent, `null` or have a value?

profgumby
replied to zbouboutchi

I've started putting some tests to confirm this behaviour in https://gitlab.com/tanna.dev/jvt.me-examples/comparing-nullable-types-for-json-marshalling-in-go - feel free to drop a Merge Request in, there's a bit of a test harness to make it easier to work with the different ways of representing the data



r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How do you represent a JSON field in Go that could be absent, `null` or have a value?

profgumby
replied to Dgt84

To evidence this claim in this comment, I've created some sample code in https://gitlab.com/tanna.dev/jvt.me-examples/comparing-nullable-types-for-json-marshalling-in-go/-/tree/main/ogen?ref_type=heads (run go test in that directory) that should validate this - would be happily corrected if I've misspoken!

I've also done the same for huma and it looks like that doesn't handle marshalling of data, only unmarshalling


r/golang icon
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online
r/golang
A banner for the subreddit

Ask questions and post articles about the Go programming language and related tools, events etc.


Members Online

How do you represent a JSON field in Go that could be absent, `null` or have a value?

Yup, part of this came about by trying to avoid JSON Patch (https://datatracker.ietf.org/doc/html/rfc6902/) by instead doing JSON Merge Patch (https://www.rfc-editor.org/rfc/rfc7386) due to some perceived complexity - either way, there's a bit of complexity 🤷🏼

But I'm happy we went this route, at least to be able to work out how to do this!


profgumby u/profgumby avatar