ha

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 5 Imported by: 0

README

ha

Usage

Database

import "github.com/woxingliu/ha/database"
go mod tidy

postgresql

pg, err := database.NewPostgresDB(
	"postgres://postgres:123456@localhost:5432/user?sslmode=disable",
	database.ConnAttempts_Postgres(10),
	database.MaxPoolSize_Postgres(4),
)
if err != nil {
	return err
}
defer pg.Close()

mariadb

mariaDB := database.NewMariaDB(
	"root:root@tcp(localhost:3306)/user?parseTime=True&loc=Local&charset=utf8mb4&collation=utf8mb4_unicode_ci",
	database.MaxIdleConns_MYSQL(4),
	database.MaxOpenConns_MYSQL(4),
)
defer mariaDB.Close()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteString

func ByteString(b []byte) string

[]byte to string

func StrconvFormatInt

func StrconvFormatInt(i int64) string

1645270804 to "1645270804"

func StrconvParseInt

func StrconvParseInt(s string) int64

"1645270804" to 1645270804

func StringByte

func StringByte(s string) (b []byte)

string to []byte

func TimeFormat

func TimeFormat(tm time.Time) string

time.Time to "2006-01-02 15:04:05"

func TimeNowFormat

func TimeNowFormat() string

time.Time to "2006-01-02 15:04:05"

func TimeParse

func TimeParse(s string) time.Time

"2006-01-02 15:04:05" to time.Time

func TimeUnix

func TimeUnix(sec int64) time.Time

1645270804 to time.Time

Types

This section is empty.

Directories

Path Synopsis
Package database implements postgres connection.
Package database implements postgres connection.
Package httpserver implements HTTP server.
Package httpserver implements HTTP server.

Jump to

Keyboard shortcuts

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