2011-05-02 01:21:22 +00:00
|
|
|
/*
|
2018-01-04 00:52:49 +00:00
|
|
|
Copyright 2011 The Perkeep Authors
|
2011-05-02 01:21:22 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-02-02 22:54:24 +00:00
|
|
|
"bytes"
|
2012-03-25 02:45:23 +00:00
|
|
|
"database/sql"
|
2013-03-20 16:10:39 +00:00
|
|
|
"errors"
|
2011-05-02 01:21:22 +00:00
|
|
|
"flag"
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"fmt"
|
2015-02-02 22:54:24 +00:00
|
|
|
"net"
|
2011-05-02 01:21:22 +00:00
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
"perkeep.org/pkg/cmdmain"
|
|
|
|
"perkeep.org/pkg/sorted/mongo"
|
|
|
|
"perkeep.org/pkg/sorted/mysql"
|
|
|
|
"perkeep.org/pkg/sorted/postgres"
|
|
|
|
"perkeep.org/pkg/sorted/sqlite"
|
2011-06-19 21:36:46 +00:00
|
|
|
|
2016-04-20 23:43:47 +00:00
|
|
|
_ "github.com/go-sql-driver/mysql"
|
|
|
|
_ "github.com/lib/pq"
|
2018-01-03 00:02:14 +00:00
|
|
|
"gopkg.in/mgo.v2"
|
2011-05-02 01:21:22 +00:00
|
|
|
)
|
|
|
|
|
2013-02-26 21:42:38 +00:00
|
|
|
type dbinitCmd struct {
|
|
|
|
user string
|
|
|
|
password string
|
|
|
|
host string
|
|
|
|
dbName string
|
|
|
|
dbType string
|
2013-06-25 04:27:23 +00:00
|
|
|
sslMode string // Postgres SSL mode configuration
|
2011-05-02 01:21:22 +00:00
|
|
|
|
2013-02-26 21:42:38 +00:00
|
|
|
wipe bool
|
|
|
|
keep bool
|
2013-03-22 23:34:08 +00:00
|
|
|
wal bool // Write-Ahead Logging for SQLite
|
2013-02-26 21:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdmain.RegisterCommand("dbinit", func(flags *flag.FlagSet) cmdmain.CommandRunner {
|
|
|
|
cmd := new(dbinitCmd)
|
|
|
|
flags.StringVar(&cmd.user, "user", "root", "Admin user.")
|
|
|
|
flags.StringVar(&cmd.password, "password", "", "Admin password.")
|
|
|
|
flags.StringVar(&cmd.host, "host", "localhost", "host[:port]")
|
2013-03-20 16:10:39 +00:00
|
|
|
flags.StringVar(&cmd.dbName, "dbname", "", "Database to wipe or create. For sqlite, this is the db filename.")
|
2013-12-13 15:07:45 +00:00
|
|
|
flags.StringVar(&cmd.dbType, "dbtype", "mysql", "Which RDMS to use; possible values: mysql, postgres, sqlite, mongo.")
|
2013-06-25 04:27:23 +00:00
|
|
|
flags.StringVar(&cmd.sslMode, "sslmode", "require", "Configure SSL mode for postgres. Possible values: require, verify-full, disable.")
|
2011-05-02 01:21:22 +00:00
|
|
|
|
2013-02-26 21:42:38 +00:00
|
|
|
flags.BoolVar(&cmd.wipe, "wipe", false, "Wipe the database and re-create it?")
|
|
|
|
flags.BoolVar(&cmd.keep, "ignoreexists", false, "Do nothing if database already exists.")
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
// Defaults to true, because it fixes http://perkeep.org/issue/114
|
2013-03-22 23:34:08 +00:00
|
|
|
flags.BoolVar(&cmd.wal, "wal", true, "Enable Write-Ahead Logging with SQLite, for better concurrency. Requires SQLite >= 3.7.0.")
|
2013-02-26 21:42:38 +00:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *dbinitCmd) Describe() string {
|
|
|
|
return "Set up the database for the indexer."
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *dbinitCmd) Usage() {
|
|
|
|
fmt.Fprintf(os.Stderr, "Usage: camtool [globalopts] dbinit [dbinitopts] \n")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *dbinitCmd) Examples() []string {
|
|
|
|
return []string{
|
|
|
|
"-user root -password root -host localhost -dbname camliprod -wipe",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *dbinitCmd) RunCommand(args []string) error {
|
|
|
|
if c.dbName == "" {
|
|
|
|
return cmdmain.UsageError("--dbname flag required")
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 15:07:45 +00:00
|
|
|
if c.dbType != "mysql" && c.dbType != "postgres" && c.dbType != "mongo" {
|
2013-03-20 16:10:39 +00:00
|
|
|
if c.dbType == "sqlite" {
|
|
|
|
if !WithSQLite {
|
|
|
|
return ErrNoSQLite
|
|
|
|
}
|
2013-03-22 23:34:08 +00:00
|
|
|
c.wal = c.wal && sqlite.IsWALCapable()
|
|
|
|
if !c.wal {
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
fmt.Print("WARNING: An SQLite indexer without Write Ahead Logging will most likely fail. See http://perkeep.org/issue/114\n")
|
2013-03-22 23:34:08 +00:00
|
|
|
}
|
2013-03-20 16:10:39 +00:00
|
|
|
} else {
|
2013-12-13 15:07:45 +00:00
|
|
|
return cmdmain.UsageError(fmt.Sprintf("--dbtype flag: got %v, want %v", c.dbType, `"mysql" or "postgres" or "sqlite", or "mongo"`))
|
2013-03-20 16:10:39 +00:00
|
|
|
}
|
2012-11-03 18:58:50 +00:00
|
|
|
}
|
2013-03-20 16:10:39 +00:00
|
|
|
|
2012-11-03 18:58:50 +00:00
|
|
|
var rootdb *sql.DB
|
|
|
|
var err error
|
2013-02-26 21:42:38 +00:00
|
|
|
switch c.dbType {
|
2012-11-03 18:58:50 +00:00
|
|
|
case "postgres":
|
2013-06-25 04:27:23 +00:00
|
|
|
conninfo := fmt.Sprintf("user=%s dbname=%s host=%s password=%s sslmode=%s", c.user, "postgres", c.host, c.password, c.sslMode)
|
2012-11-03 18:58:50 +00:00
|
|
|
rootdb, err = sql.Open("postgres", conninfo)
|
|
|
|
case "mysql":
|
2018-01-11 22:34:16 +00:00
|
|
|
// need to use an empty dbname to query tables
|
|
|
|
rootdb, err = sql.Open("mysql", c.mysqlDSN(""))
|
2012-11-03 18:58:50 +00:00
|
|
|
}
|
2011-05-02 01:21:22 +00:00
|
|
|
if err != nil {
|
2013-02-26 21:42:38 +00:00
|
|
|
exitf("Error connecting to the root %s database: %v", c.dbType, err)
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
|
|
|
|
2018-01-11 22:34:16 +00:00
|
|
|
// Validate the DSN to avoid confusion here
|
|
|
|
err = rootdb.Ping()
|
|
|
|
if err != nil {
|
|
|
|
exitf("Error connecting to the root %s database: %v", c.dbType, err)
|
|
|
|
}
|
|
|
|
|
2013-02-26 21:42:38 +00:00
|
|
|
dbname := c.dbName
|
2013-12-13 15:07:45 +00:00
|
|
|
exists := c.dbExists(rootdb)
|
2011-05-02 01:21:22 +00:00
|
|
|
if exists {
|
2013-02-26 21:42:38 +00:00
|
|
|
if c.keep {
|
|
|
|
return nil
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
2013-02-26 21:42:38 +00:00
|
|
|
if !c.wipe {
|
|
|
|
return cmdmain.UsageError(fmt.Sprintf("Database %q already exists, but --wipe not given. Stopping.", dbname))
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
2013-12-13 15:07:45 +00:00
|
|
|
if c.dbType == "mongo" {
|
|
|
|
return c.wipeMongo()
|
|
|
|
}
|
2013-03-20 16:10:39 +00:00
|
|
|
if c.dbType != "sqlite" {
|
|
|
|
do(rootdb, "DROP DATABASE "+dbname)
|
|
|
|
}
|
|
|
|
}
|
2013-12-13 15:07:45 +00:00
|
|
|
switch c.dbType {
|
|
|
|
case "sqlite":
|
2013-03-20 16:10:39 +00:00
|
|
|
_, err := os.Create(dbname)
|
|
|
|
if err != nil {
|
|
|
|
exitf("Error creating file %v for sqlite db: %v", dbname, err)
|
|
|
|
}
|
2013-12-13 15:07:45 +00:00
|
|
|
case "mongo":
|
|
|
|
return nil
|
2013-12-23 15:30:28 +00:00
|
|
|
case "postgres":
|
|
|
|
// because we want string comparison to work as on MySQL and SQLite.
|
|
|
|
// in particular we want: 'foo|bar' < 'foo}' (which is not the case with an utf8 collation apparently).
|
|
|
|
do(rootdb, "CREATE DATABASE "+dbname+" LC_COLLATE = 'C' TEMPLATE = template0")
|
2013-12-13 15:07:45 +00:00
|
|
|
default:
|
2013-03-20 16:10:39 +00:00
|
|
|
do(rootdb, "CREATE DATABASE "+dbname)
|
2012-03-26 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
2012-11-03 18:58:50 +00:00
|
|
|
var db *sql.DB
|
2013-02-26 21:42:38 +00:00
|
|
|
switch c.dbType {
|
2012-11-03 18:58:50 +00:00
|
|
|
case "postgres":
|
2013-06-25 04:27:23 +00:00
|
|
|
conninfo := fmt.Sprintf("user=%s dbname=%s host=%s password=%s sslmode=%s", c.user, dbname, c.host, c.password, c.sslMode)
|
2012-11-03 18:58:50 +00:00
|
|
|
db, err = sql.Open("postgres", conninfo)
|
2013-03-20 16:10:39 +00:00
|
|
|
case "sqlite":
|
|
|
|
db, err = sql.Open("sqlite3", dbname)
|
2012-11-03 18:58:50 +00:00
|
|
|
default:
|
2015-02-02 22:54:24 +00:00
|
|
|
db, err = sql.Open("mysql", c.mysqlDSN(dbname))
|
2012-11-03 18:58:50 +00:00
|
|
|
}
|
2012-03-26 20:57:53 +00:00
|
|
|
if err != nil {
|
2013-03-20 16:10:39 +00:00
|
|
|
return fmt.Errorf("Connecting to the %s %s database: %v", dbname, c.dbType, err)
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
2011-06-19 21:36:46 +00:00
|
|
|
|
2013-02-26 21:42:38 +00:00
|
|
|
switch c.dbType {
|
2012-11-03 18:58:50 +00:00
|
|
|
case "postgres":
|
|
|
|
for _, tableSql := range postgres.SQLCreateTables() {
|
|
|
|
do(db, tableSql)
|
|
|
|
}
|
|
|
|
for _, statement := range postgres.SQLDefineReplace() {
|
|
|
|
do(db, statement)
|
|
|
|
}
|
|
|
|
doQuery(db, fmt.Sprintf(`SELECT replaceintometa('version', '%d')`, postgres.SchemaVersion()))
|
|
|
|
case "mysql":
|
2014-08-08 17:29:05 +00:00
|
|
|
if err := mysql.CreateDB(db, dbname); err != nil {
|
2018-01-11 22:34:16 +00:00
|
|
|
exitf("error in CreateDB(%s): %v", dbname, err)
|
2014-08-08 17:29:05 +00:00
|
|
|
}
|
|
|
|
for _, tableSQL := range mysql.SQLCreateTables() {
|
|
|
|
do(db, tableSQL)
|
2012-11-03 18:58:50 +00:00
|
|
|
}
|
|
|
|
do(db, fmt.Sprintf(`REPLACE INTO meta VALUES ('version', '%d')`, mysql.SchemaVersion()))
|
2013-03-20 16:10:39 +00:00
|
|
|
case "sqlite":
|
|
|
|
for _, tableSql := range sqlite.SQLCreateTables() {
|
|
|
|
do(db, tableSql)
|
|
|
|
}
|
2013-03-22 23:34:08 +00:00
|
|
|
if c.wal {
|
|
|
|
do(db, sqlite.EnableWAL())
|
|
|
|
}
|
2013-03-20 16:10:39 +00:00
|
|
|
do(db, fmt.Sprintf(`REPLACE INTO meta VALUES ('version', '%d')`, sqlite.SchemaVersion()))
|
2011-06-19 21:36:46 +00:00
|
|
|
}
|
2013-02-26 21:42:38 +00:00
|
|
|
return nil
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
|
|
|
|
2012-03-25 02:45:23 +00:00
|
|
|
func do(db *sql.DB, sql string) {
|
|
|
|
_, err := db.Exec(sql)
|
2013-02-26 21:42:38 +00:00
|
|
|
if err != nil {
|
2014-08-08 15:24:48 +00:00
|
|
|
exitf("Error %q running SQL: %q", err, sql)
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-03 18:58:50 +00:00
|
|
|
func doQuery(db *sql.DB, sql string) {
|
|
|
|
r, err := db.Query(sql)
|
|
|
|
if err == nil {
|
|
|
|
r.Close()
|
|
|
|
return
|
|
|
|
}
|
2014-08-08 15:24:48 +00:00
|
|
|
exitf("Error %q running SQL: %q", err, sql)
|
2012-11-03 18:58:50 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 15:07:45 +00:00
|
|
|
func (c *dbinitCmd) dbExists(db *sql.DB) bool {
|
2012-11-03 18:58:50 +00:00
|
|
|
query := "SHOW DATABASES"
|
2013-12-13 15:07:45 +00:00
|
|
|
switch c.dbType {
|
2012-11-03 18:58:50 +00:00
|
|
|
case "postgres":
|
|
|
|
query = "SELECT datname FROM pg_database"
|
|
|
|
case "mysql":
|
|
|
|
query = "SHOW DATABASES"
|
2013-03-20 16:10:39 +00:00
|
|
|
case "sqlite":
|
|
|
|
// There is no point in using sql.Open because it apparently does
|
|
|
|
// not return an error when the file does not exist.
|
2013-12-13 15:07:45 +00:00
|
|
|
fi, err := os.Stat(c.dbName)
|
2013-06-23 00:51:09 +00:00
|
|
|
return err == nil && fi.Size() > 0
|
2013-12-13 15:07:45 +00:00
|
|
|
case "mongo":
|
|
|
|
session, err := c.mongoSession()
|
|
|
|
if err != nil {
|
|
|
|
exitf("%v", err)
|
|
|
|
}
|
|
|
|
defer session.Close()
|
|
|
|
n, err := session.DB(c.dbName).C(mongo.CollectionName).Find(nil).Limit(1).Count()
|
|
|
|
if err != nil {
|
|
|
|
exitf("%v", err)
|
|
|
|
}
|
|
|
|
return n != 0
|
2012-11-03 18:58:50 +00:00
|
|
|
}
|
|
|
|
rows, err := db.Query(query)
|
2018-01-11 22:34:16 +00:00
|
|
|
check(err, query)
|
2012-03-25 02:45:23 +00:00
|
|
|
defer rows.Close()
|
|
|
|
for rows.Next() {
|
|
|
|
var db string
|
2018-01-11 22:34:16 +00:00
|
|
|
check(rows.Scan(&db), query)
|
2013-12-13 15:07:45 +00:00
|
|
|
if db == c.dbName {
|
2011-05-02 01:21:22 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-01-11 22:34:16 +00:00
|
|
|
func check(err error, query string) {
|
2011-05-02 01:21:22 +00:00
|
|
|
if err == nil {
|
|
|
|
return
|
|
|
|
}
|
2018-01-11 22:34:16 +00:00
|
|
|
exitf("SQL error for query %q: %v", query, err)
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func exitf(format string, args ...interface{}) {
|
|
|
|
if !strings.HasSuffix(format, "\n") {
|
|
|
|
format = format + "\n"
|
|
|
|
}
|
2014-08-08 15:24:48 +00:00
|
|
|
cmdmain.Errorf(format, args...)
|
2013-02-26 21:42:38 +00:00
|
|
|
cmdmain.Exit(1)
|
2011-05-02 01:21:22 +00:00
|
|
|
}
|
2013-03-20 16:10:39 +00:00
|
|
|
|
|
|
|
var WithSQLite = false
|
|
|
|
|
2013-09-19 09:17:57 +00:00
|
|
|
var ErrNoSQLite = errors.New("the command was not built with SQLite support. See https://code.google.com/p/camlistore/wiki/SQLite" + compileHint())
|
2013-03-20 16:10:39 +00:00
|
|
|
|
|
|
|
func compileHint() string {
|
|
|
|
if _, err := os.Stat("/etc/apt"); err == nil {
|
|
|
|
return " (Required: apt-get install libsqlite3-dev)"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
2013-12-13 15:07:45 +00:00
|
|
|
|
|
|
|
// mongoSession returns an *mgo.Session or nil if c.dbtype is
|
|
|
|
// not "mongo" or if there was an error.
|
|
|
|
func (c *dbinitCmd) mongoSession() (*mgo.Session, error) {
|
|
|
|
if c.dbType != "mongo" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
url := ""
|
|
|
|
if c.user == "" || c.password == "" {
|
|
|
|
url = c.host
|
|
|
|
} else {
|
|
|
|
url = c.user + ":" + c.password + "@" + c.host + "/" + c.dbName
|
|
|
|
}
|
|
|
|
return mgo.Dial(url)
|
|
|
|
}
|
|
|
|
|
|
|
|
// wipeMongo erases all documents from the mongo collection
|
|
|
|
// if c.dbType is "mongo".
|
|
|
|
func (c *dbinitCmd) wipeMongo() error {
|
|
|
|
if c.dbType != "mongo" {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
session, err := c.mongoSession()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer session.Close()
|
|
|
|
if _, err := session.DB(c.dbName).C(mongo.CollectionName).RemoveAll(nil); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2015-02-02 22:54:24 +00:00
|
|
|
|
|
|
|
func (c *dbinitCmd) mysqlDSN(dbname string) string {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
fmt.Fprintf(&buf, "%s:%s@", c.user, c.password)
|
|
|
|
if c.host != "localhost" {
|
|
|
|
host := c.host
|
|
|
|
if _, _, err := net.SplitHostPort(host); err != nil {
|
|
|
|
host = net.JoinHostPort(host, "3306")
|
|
|
|
}
|
|
|
|
fmt.Fprintf(&buf, "tcp(%s)", host)
|
|
|
|
}
|
|
|
|
fmt.Fprintf(&buf, "/%s", dbname)
|
|
|
|
return buf.String()
|
|
|
|
}
|