mycnf

package module
v0.0.0-...-99e4e75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2024 License: GPL-3.0 Imports: 3 Imported by: 2

README

mycnf

Read a .my.cnf file and extract credentials and other details to connect to a MySQL database.

func ReadMyCnf reads a .my.cnf (~/.my.cnf by default), searches for the named "profile" in that file and returns a DSN (string) suitable for use in sql.Open().

This is based on a gist from https://gist.github.com/nickcarenza and modified to accept default values passed in a structure from the calling function.

Read the complete documentation at GoDoc.

Documentation

Overview

mycnf provides access to MySQL configuration files (in .ini format). Based on code from https://gist.github.com/nickcarenza/d847ec24455e70a8609b6602ed528133

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadMyCnf

func ReadMyCnf(configFile *string, profile string) (map[string]string, error)

ReadMyCnf reads a .my.cnf section "profile", fills in missing values in the passed structure, and returns a DSN suitable for use in db.Open(). ReadMyCnf returns an error only if there was an actual error attempting to access the file. Not finding the file or the "profile" within the file is not an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL