Skip to main content

All Questions

Tagged with
-2 votes
0 answers
30 views

Golang test cases for gin failing [closed]

Hi All I am trying to create a test cases for my gin gonic framework where I am using Gorm and ORM but I am getting errors like this: [31m2024/07/03 08:48:19 [Recovery] 2024/07/03 - 08:48:19 panic ...
Nilay Singh's user avatar
  • 2,287
-1 votes
1 answer
44 views

Cannot use exported method that belongs to the package in Golang

I've got a package named services. This is the structure of the package: services/ third_party/ discogs.go discogsAPIStructs.go artist_srv.go auth_srv.go record_srv.go ...
MrCujo's user avatar
  • 1,253
1 vote
0 answers
45 views

Facing issues with the Join Query in the Go Project using MySQL Database

I am creating a go project and facing an issue with the join query. I am not getting the columns of the joined tables in the project using GORM/GIN. But when I debug that query and use it in the MySQL,...
ghanshyam's user avatar
1 vote
1 answer
54 views

Error uploading file while creating a new user in Golang

Below is the controller to create new user. I have used it without the code of file upload(placed string instead). It's working perfect. But this code shows below error. I am not getting any specific ...
ghanshyam's user avatar
2 votes
0 answers
610 views

go lang rest api return WHERE conditions required

Update handler for rest api /address/:id func (s *Server) UpdateAddressByID(id int, updatedAddress *model.Address) error { // Get the address by ID var address model.Address if err := s.DB....
Stepan Kutaj's user avatar
1 vote
1 answer
62 views

Wrong return value in golang restapi

i am new in GOLANG ... and now I trying create rest api with gin and retrieve data from mysql using GORM... table structure. type Movie struct { gorm.Model Title string Description ...
Stepan Kutaj's user avatar
1 vote
0 answers
77 views

How to effectively organize tests for Gin/GORM based web-apps?

I am quite new to web development in Golang using Gin/GORM and I am currently struggling to find out the best practice to organize packages and unit-tests. The problem arises from the fact I would ...
wandering-tales's user avatar
1 vote
0 answers
55 views

Go Gorm Gin Json

I have a structure that contains another structure. This structures represent the tables in my DB. I define connections between them through Gorm tags. As the result, when I pass this structure as ...
Nikita's user avatar
  • 19
0 votes
0 answers
40 views

failed to initialize database, got error dial tcp 127.0.0.1:3306: connect: connection refused panic: An error occured [duplicate]

When I run my code using go run . it runs and the database tables get created successfully, but when I use docker run mybackend:multistage , I get this error: failed to initialize database, got error ...
Joel Swakise TheDancer's user avatar
2 votes
0 answers
335 views

Default Param value for Gin-Swagger

I am using gin-swagger to prepare an OpenAPI for my Go project. I have a gorm struct that includes a time.Time parameter called Published. type Book struct { gorm.Model `swaggerignore:"true&...
محمد جعفر نعمة's user avatar
1 vote
0 answers
332 views

Gorm.Model ID as UUID with Mysql not allowing creation of data

I'm writing a Go (1.20) backend in Gin (v1.9.1) backend with Gorm (1.25.3), and for my data models I want to use UUID's as the ID. I've been trying to find a way to do this but always end up getting ...
Kristófer Fannar Björnsson's user avatar
1 vote
0 answers
198 views

BeforeSave Gorm trigger to insert field into another table if not existing

I have SQL Syntax that I need to convert to Gorm to be executed before a insertion into a table. Executing with prepared statement isn't supported yet even after trimming out the delimiters. Here's ...
O'Brien's user avatar
  • 43
2 votes
0 answers
131 views

How to do a unit-test in Handler layer in go?(Using gorm,,gin)

Recently I started writing unit tests on go.I received a task to conduct tests on all layers.I did it successfully on the repository and service layer, but there were problems on the handlers.I corny ...
Cor4ik's user avatar
  • 21
1 vote
0 answers
75 views

using auto preload in golang orm - gorm

I am trying to use the Preload method on gorm database instance to auto preload implicitly by using the gorm:"PRELOAD" tag as i found in this post here.I find this not working my model is as ...
Dante 's user avatar
  • 349
1 vote
0 answers
140 views

Issue with Gorm and Gin

I am facing an issue with Gorm using Gin. On the code level, there have been no changes. However, the issue that I am facing is that when I run a query using Gorm, it gives me no records, while when I ...
Shivam Singhal's user avatar

15 30 50 per page
1
2 3 4 5
7