Git Product home page Git Product logo

pqdsn's Introduction

Build Status codecov PkgGoDev Go Report Card

PQDSN

Package pqdsn offers a type safe way of build Data Source Names for lib/pq. Parameters struct type holds all accepted lib/pq parameters. The String() method returns a Data Source Name in the format of:

"user=pqgotest dbname=pqgotest sslmode=verify-full"

Example

p := Parameters{
    DBname:   "pqgotest",
    User:     "pqgotest",
    Password: "secret",
    Host:     "db.example.com",
    Port:     1234,
    SSLmode:  SSLVerifyFull,
    // Use single quotes in values with space!
    FallbackApplicationName: "'pqdsn test'",
}

dsn := p.String()
fmt.Println(dsn)

Output:

dbname=pqgotest user=pqgotest password=secret host=db.example.com port=1234 sslmode=verify-full fallback_application_name='pqdsn test'

Benchmarks

goos: linux
goarch: amd64
pkg: github.com/moapis/pqdsn
BenchmarkBuilder_addString-8                     2407327               461 ns/op             273 B/op          1 allocs/op
BenchmarkParameters_String-8                     2853232               423 ns/op             356 B/op          4 allocs/op
BenchmarkParameters_EscapedString_esc-8          1000000              1099 ns/op             644 B/op          5 allocs/op
PASS
ok      github.com/moapis/pqdsn 4.398s

License

Copyright (c) 2020, Mohlmann Solutions SRL. All rights reserved. Use of this source code is governed by a License that can be found in the LICENSE file.

pqdsn's People

Contributors

muhlemmer avatar

Stargazers

Eliah Rusin avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.