Multicolumn index on 3 fields with heterogenous data types

I have a postgres table with 3 fields: a : postgis geometry b : array varchar[] c : integer and I have a query that involves all of them. I would like to add a multicolumn index to speed it up...

Go gin framework CORS

I'm using Go gin framework gin func CORSMiddleware() gin.HandlerFunc { return func(c *gin.Context) { c.Writer.Header().Set("Content-Type", "application/json") ...

Returning JSON data as a stream per chunk to Angular2 or jQuery over HTTP2 (HTTPS)

In one of my API's I mostly return a result (let's say paged 50 results) as one whole in an json array like so: [{},{},{},{},{},...] I was wondering if there are better ways of doing this over...

How to return html on Gin?

I'm trying to render a HTML that's already on a string instead of rendering a template on Gin framework. The c.HTML function on GET("/") function expects a template to be rendered. But on...

Golang Gin-Gonic Split Routes into Multiple Files

I am looking to split my routes.go into multiple files so that each group is in its own package. Can someone point me to an example of some code where someone has done this with Gin? i.e. package...

gin-gonic mapping request.body values into a struct

Am new to the GO programming language. I am building a web server using the gin-gonic framework. I am trying to map the values from req.body onto a struct. Using Postman I am sending a POST...

How to get header data of postman using gin package in golang?

I want to get the header data using gin package(golang) in the postman but I don't get any idea how to do it. I search it for google but not getting any answer. Can anyone help me to get the data...

Implement the JWT middleware in golang using gin package and secure the other APIs?

I want to secure my APIs that an authorized user can access my APIs. Here the router is given below:- Router.go //here the customer will register. Route{"SaveUser", "POST", "/signup",...

Apache thrift err in PHP Client and Golang Server

when i use Apache Thrift PHP client and PHP server is OK, but When I use Golang as Server, is not OK, I find nothing in the internet that about Golang thrift use Http mode,The document only show...

Cors doesnt work on gin and golang group routes

I try this specific code but it keep on giving me error in No 'Access-Control-Allow-Origin' package main import ( "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) func main() { ...

path segment conflicts with existing wildcard in path

I want to rewrite flask application in golang-gin, and i have a path problem in routes, :status have only 3 version start pause end , this is my current routes : contracts.POST("/:id/:status",...

Go 1.12 modules: local import in non-local import

I'm currently using Go 1.12 modules and really tired about importing. I'm making the rest-api using gin(web microservices) and gorm(golang orm). Everything still ok while working in golang...

How to correctly set Mock Row and Query for go-sqlmock

I'm setting up testing in golang. I use go-sqlmock to test mysql connection. But sqlmock.NewRows and mock.ExpectQuery does not work well with error. I want to know how to resolve this...

How to set mock gin.Context for BindJSON

I'm setting up testing in Go. I use go-sqlmock to test mysql connection and Go Gin as framework. Now I try to test mysql insert logic. The problem is I need to set mock gin.Context which is used...

Unit Testing With Gin-Gonic

My project is split into three main components: controllers, services, and models. When a route is queried via the URI, the controllers are called, which then call the services to interact with...

Nginx(as reverse proxy) does not notify gin-gonic(as web server) when connection canceled by client

In a website which uses gin-gonic as webserver and nginx as a proxy server, clients send their data to the server via gin-gonic exposed APIs, and — in order to send server commands to clients...

Go gin get request body json

Im using postman to post data and in the body Im putting some simple json Request Body { "order":"1", "Name":"ts1" } I need to transfer the data to json and I try like following, and I wasnt...

error when building , getting : "suspect or "

I'm encountering a build issue with go. I'm wondering if it's a bug in the compiler or a problem with the code. // removed the error handling for sake of clarity file, _ :=...

After go install the import doesn't recognize the package

Hi I'm pretty new at Golang, after install it I would like to use the next package in my project: https://github.com/gin-gonic/gin After I created my project, I did the next command to install...

How do I find the request method from Go Gin context?

I want to use the same handler for multiple endpoints in a Go Gin app: router.POST("/box/:boxID", controllers.AddUpdateBox) router.PUT("/box/:boxID", controllers.AddUpdateBox) ...

Importing Kubectl Descriptor Results In Kustomize Incompatible Error

My project references to many public APIs, and it looks like they conflict with each other and results compilation error. Here is my go.mod module github.com/apulis/job-scheduler go...

How to serve static files from all routes except one in Gin?

As the title says, consider a Gin router where I want to serve static files from all routes except one. Let's say this one route is /api. A first attempt might look like this: package main import...

Serving react static files in golang gin-gonic using go:embed giving 404 error on reloading on frontend URL

I have built a go application using gin and go1.17. I am using go:embed to to serve static content for a SPA app built using react. (trying the approach as suggested in...

Gin not binding validation in array nested struct

I have a problem. This problem is about validation binding in gin framework (golang). If I request for an endpoint with (request below) has result success, my expectation is to show error...

Trying to make a HTTP request and return the result of that request in an app that uses go/gin

I just picked up Go yesterday and I was wondering how I can make an HTTP request and return the result of that request with my API made with Gin. This is the code for the endpoint that returns the...

Is it possible to update the log level of a zap logger at runtime?

I created a logger with kubebuilder, it is based on zap logger: import ( "flag" "github.com/gin-gonic/gin" "net/http" "os" "go.uber.org/zap/zapcore" uzap "go.uber.org/zap" ...

consul health check (All service checks failing)

I have read the similar question related to this problem. It ended up with frustration. I installed consul with docker. I run the following command. docker run --name consul -d -p 8500:8500...

golang gin middleware unit testing

I have a middleware handler function and I would like to be able to write unit tests for this function. How might I go about doing this in GoLang? I would like to be able to verify when I call to...

How to handle errors in Gin middleware

I want to grab all http errors on each route without rewrite each time if 400 then if 404 then if 500 then etc... so I have an ErrorHandler() function inside each route handler: func (h *Handler)...

Can't install gin-gonic (Windows 10)

I can't install gin-gonic for my golang project. I tried reinstalling go, resetting the bash files, delete and recreate the project folder, and searched the error as keyword on google, but found...