sqlx VS gomock

Compare sqlx vs gomock and see what are their differences.


general purpose extensions to golang's database/sql (by jmoiron)


GoMock is a mocking framework for the Go programming language. (by golang)
Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • SonarLint - Clean code begins in your IDE with SonarLint
  • SaaSHub - Software Alternatives and Reviews
sqlx gomock
63 35
13,447 8,653
- 2.4%
0.0 3.7
6 days ago about 1 month ago
Go Go
MIT License Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.


Posts with mentions or reviews of sqlx. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-03-23.
  • Where Is the Spring Framework for Go?
    2 projects | reddit.com/r/golang | 23 Mar 2023
    This is the same situation I saw 20 years ago. Back then, all the managers were pushing development in Oracle tools. Those managers grew up on Oracle and Java was too modern for them. Now the situation is similar. Managers used to do things in Java and now they are still pushing Java. In fact, today Java brings nothing but problems. When I see a new project starting on Java it is always some big desperation. For a comparison of Java and Go, just look at the documentation for SQL. For go: https://pkg.go.dev/database/sql (31 pages) and maybe https://jmoiron.github.io/sqlx/ (12 pages). In Java only one class is 59 pages (https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html) and look how many of those documents there are: https://docs.oracle.com/en/java/javase/13/docs/api/java.sql/java/sql/package-summary.html and on top of that we have javax.sql - https://docs.oracle.com/javase/8/docs/api/javax/sql/package-summary.html And even then you use Hibernate for example, where the documentation has 11 manuals and of those the User Guide has 353 pages - https://docs.jboss.org/hibernate/orm/6.2/userguide/html\_single/Hibernate\_User\_Guide.html
  • Is sqlx still maintained?
    2 projects | reddit.com/r/golang | 15 Mar 2023
  • Golang tech stack
    11 projects | reddit.com/r/golang | 12 Mar 2023
  • What framework to build heavy i/o rest api?
    3 projects | reddit.com/r/golang | 11 Mar 2023
    If you care about performance you might want to avoid an ORM all together and just write out the queries you need. We use sqlx in those cases.
  • Java é o novo Javascript do momento?
    3 projects | reddit.com/r/brdev | 7 Mar 2023
  • GORM
    16 projects | reddit.com/r/golang | 16 Feb 2023
    or in general for accessing databases? * sqlx: general purpose extensions to database/sql * sqlc: generate type safe code from queries * squirrel: fluent SQL generator
  • ORM or no ORM (and which ones)?
    17 projects | reddit.com/r/golang | 17 Jan 2023
    https://github.com/jmoiron/sqlx and github.com/lib/pq are pretty solid, this is what i go to.
  • Does Go need overcoding for tasks that other languages can execute in one liners (or with less code)?
    6 projects | reddit.com/r/golang | 14 Nov 2022
    The amount of packages imported is kind of a thing I want to remove. There is, for example, MySQL package but I use PG. Also, for many things I need sqlx, sometimes database/sql + carta. I would love to standardize all my database handling to make it simple, concise, and efficient;
  • Creating an API using Go and sqlc
    5 projects | dev.to | 24 Oct 2022
    Implement the Repository interface by writing the queries in code, perhaps using some solution like Squirrel or sqlx.
  • How do you handle scanning of db.Rows?
    2 projects | reddit.com/r/golang | 17 Oct 2022
    Hey, have you looked at sqlx?


Posts with mentions or reviews of gomock. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-03-06.
  • Is gomock still maintained and recommended?
    7 projects | reddit.com/r/golang | 6 Mar 2023
    Looking at gomock's commit history, it seems like there hasn't been much activity on the project in a couple of years. I'm wondering if this is the case of software being mostly done and just in maintenance mode, or if gomock is falling behind. The reason I fear for the latter is there are still issues being opened up that don't seem to be engaged very much.
  • Want to know if this is a valid approach
    2 projects | reddit.com/r/golang | 2 Mar 2023
    Yeah, that would work just fine. Nevertheless, as your business logic gets more complicated, you will want to test more scenarios and mocks will get complicated fast. In these cases tools like gomock really shine and make your life easier. I understand that this is a just-for-fun project, but it's never too early to experiment with a popular solution, especially if you plan on using Go professionally in the future.
  • Go API Project Set-Up
    7 projects | dev.to | 23 Dec 2022
    Unit tests are leveraged to test individual units of code. As such it is not recommended for a developer to scaffold entire dependencies for the sake of testing a single object. Due to the way Go's specific implementations work, I've learned over time to declare interfaces for a lot of the structs that I use in Go. Interfaces not only define a contract for which struct-based implementations should adhere, but they also provide a mechanism for which struct methods can be mocked. While I've experimented with the mock package in testify, I've come to prefer the mock functionality which is provided by mockgen.
  • Google's internal Go style guide
    5 projects | reddit.com/r/golang | 18 Nov 2022
    Where we do use mocks, we primarily use GoMock.
  • How do you write/generate mocks for testing?
    5 projects | reddit.com/r/golang | 21 Sep 2022
    Currently migrating from moq to https://github.com/golang/mock
  • golang unit testing
    3 projects | dev.to | 3 Sep 2022
    I use gomock or mockery for mocking the interfaces and testify for evaluating tests
  • How we wrote Tarantool Kubernetes Operator
    13 projects | dev.to | 29 Jul 2022
    As every software, the operator needs to be tested. In our case, we use two types of tests: Unit and E2E. For testing, usually mock code generation is used (for example, via golang/mock). We didn't like this option, so we decided to use Testify's mock module that allows to mock required function interfaces using the reflection API—the interfaces used to configure Tarantool.
  • how to mock DBs
    13 projects | reddit.com/r/golang | 30 May 2022
    In all other layers, my repositories are mocked using https://github.com/golang/mock
    13 projects | reddit.com/r/golang | 30 May 2022
  • How do you decide you are gonna use interface?
    2 projects | reddit.com/r/golang | 2 May 2022
    If you don't know how to mock databases, checkout some tutorials on it, it's a big topic, and I can't give you all the details on it. Checkout these repositories, they are used for mocking in golang https://github.com/golang/mock, https://github.com/stretchr/testify

What are some alternatives?

When comparing sqlx and gomock you can also consider the following projects:

pgx - PostgreSQL driver and toolkit for Go

sqlc - Generate type-safe code from SQL

mockery - A mock code autogenerator for Golang

Testify - A toolkit with common assertions and mocks that plays nicely with the standard library

Squirrel - Fluent SQL generation for golang

go-sql-driver/mysql - Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

monkey - Monkey patching in Go

counterfeiter - A tool for generating self-contained, type-safe test doubles in go

go-sqlmock - Sql mock driver for golang to test database interactions

SQLBoiler - Generate a Go ORM tailored to your database schema.

minimock - Powerful mock generation tool for Go programming language