viper VS validator

Compare viper vs validator and see what are their differences.

viper

Go configuration with fangs (by spf13)

validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving (by go-playground)
Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • ONLYOFFICE ONLYOFFICE Docs — document collaboration in your environment
  • SonarQube - Static code analysis for 29 languages.
viper validator
66 59
22,999 13,226
- 1.7%
8.9 8.9
8 days ago 7 days ago
Go Go
MIT License MIT License
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.

viper

Posts with mentions or reviews of viper. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-04-17.

validator

Posts with mentions or reviews of validator. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-05-21.
  • Request Validations in Go REST API
    6 projects | reddit.com/r/golang | 21 May 2023
    I use https://github.com/go-playground/validator, but honestly, I am not a fan. I just haven’t found anything better.
  • Tools besides Go for a newbie
    36 projects | reddit.com/r/golang | 26 Mar 2023
    IDE: use whatever make you productive. I personally use vscode. VCS: git, as golang communities use github heavily as base for many libraries. AFAIK Linter: use staticcheck for linting as it looks like mostly used linting tool in go, supported by many also. In Vscode it will be recommended once you install go plugin. Libraries/Framework: actually the standard libraries already included many things you need, decent enough for your day-to-day development cycles(e.g. `net/http`). But here are things for extra: - Struct fields validator: validator - Http server lib: chi router , httprouter , fasthttp (for non standard http implementations, but fast) - Web Framework: echo , gin , fiber , beego , etc - Http client lib: most already covered by stdlib(net/http), so you rarely need extra lib for this, but if you really need some are: resty - CLI: cobra - Config: godotenv , viper - DB Drivers: sqlx , postgre , sqlite , mysql - nosql: redis , mongodb , elasticsearch - ORM: gorm , entgo , sqlc(codegen) - JS Transpiler: gopherjs - GUI: fyne - grpc: grpc - logging: zerolog - test: testify , gomock , dockertest - and many others you can find here
  • popularity behind pydantic
    2 projects | reddit.com/r/Python | 24 Mar 2023
    I work in Go now, it's crazy poor in that regard - let's just mention for instance "zero values" ( so things can remain uninitialized with a default value you can't choose ), recurring questions around "empty vs null vs not set", and everyone using go-playground/validator where you attach rules as comments ( "tags" really, but it's barely the same thing ) that are interpreted at runtime, extremely cumbersome to extend. And all that with an insane amount of boilerplate and footguns. But what really takes the cake: if you dare saying it's extremely weak you'll get shut down by the community. You're supposed to praise it, and indeed, hate python ( you know, that toy language that didn't evolve since 2008 ).
  • 3 Ways I Keep My Rest APIs endpoints down to 4-6 lines and eliminate boilerplate. What are yours?
    3 projects | reddit.com/r/golang | 4 Mar 2023
    This function requires that I'm using the validator package
  • Stop downvoting legitimate questions and comments even if you disagree with them
    2 projects | reddit.com/r/golang | 2 Mar 2023
  • What was your greatest struggle when learning Go?
    5 projects | reddit.com/r/golang | 18 Feb 2023
    You can use a validator engine like go-validator.
  • opinions on golang's JSON processing
    2 projects | reddit.com/r/golang | 15 Feb 2023
  • Best practices of validation on web apps?
    3 projects | reddit.com/r/golang | 10 Feb 2023
  • Go custom struct validation - the idiomatic way
    2 projects | dev.to | 14 Jan 2023
    In the previous blog, we had gone over struct validations in golang using validator library. Continuing on, in this blog, we'll cover custom validations.
  • Yet another validator
    2 projects | reddit.com/r/golang | 8 Jan 2023
    It aims to provide playground-like errors and validator configuration, but with Go code instead of field attributes. The second main goal is much better performance.

What are some alternatives?

When comparing viper and validator you can also consider the following projects:

godotenv - A Go port of Ruby's dotenv library (Loads environment variables from .env files)

envconfig - Small library to read your configuration from environment variables

ozzo-validation - An idiomatic Go (golang) validation package. Supports configurable and extensible validation rules (validators) using normal language constructs instead of error-prone struct tags.

koanf - Simple, extremely lightweight, extensible, configuration management library for Go. Support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.

govalidator - [Go] Package of validators and sanitizers for strings, numerics, slices and structs

grpc-go - The Go language implementation of gRPC. HTTP/2 based RPC

kelseyhightower/envconfig - Golang library for managing configuration data from environment variables

mapstructure - Go library for decoding generic map values into native Go structures and vice versa.

ini - Package ini provides INI file read and write functionality in Go

cleanenv - ✨Clean and minimalistic environment configuration reader for Golang

goConfig - goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.

config - JSON or YAML configuration wrapper with convenient access methods.