Git Product home page Git Product logo

util's Introduction

util 常用工具整理

安装

go get github.com/darcyjoven/util

exel

logger

import "github.com/darcyjoven/util/logger"
...
    // 路径,日志文件名,文件后缀
    logger.Execute("./", "gomail", "log")
...

mail

import "github.com/darcyjoven/util/mail"

func main(){
    m := mail.NewMail(&EmailPara{
        // 主题
		Subject:    "无附件",
        // 正文
		Content:    []byte("无附件邮件"),
        // 不写也可以
		Types:      "text/plain;charset=utf-8",
        // 第一个为文件名,第二个是文件路径
		Attachment: map[string]string{"mail_test.go": "mail_test.go"},
        // 收件人,抄送,秘宋
		To:         []string{"[email protected]"},
		Cc:         []string{"[email protected]"},
		Bcc:        []string{"[email protected]"},
        // 邮件服务器配置
        // 用户
		User:       "[email protected]",
        // 邮件服务器地址
		Host:       "smtp.qiye.aliyun.com",
        // 端口
		Port:       "80",
        // 密码
		Password:   "aliyunxxx",
	})
	err := m.Send()
	if err != nil {
		log.Println(err)
		return
	}
}

util

import "github.com/darcyjoven/util"
...
// markdown 转为html,目前样式是默认的
util.MarkTotHtml(byte[]("# 111"))
...
// 数字转为字母 1->A,26->Z,52->BZ...
util.NumToLetter(12)
...
// 短日期  20220710
util.GetShortDate()
...
// 长日期20220710150405000
util.GetLongDate()
...

database

import (
	"github.com/darcyjoven/util/database"
	// 你需要的数据库驱动
	_ "github.com/sijms/go-ora/v2"
)
func main(){
	d,err:=database.NewDB("oracle","connect-string")
	defer d.Close()
...
	data:=d.GetData("querystr",1,time.now)
	
	item:=d.Fetch("querystr",1,time.now)
	
	rows:=d.Foreach("querystr",1,time.now)
	for rows.Next(){
		item:=rows.Fetch()
	}
...
	cnt,err := d.Exec("some sql",1)
}

util's People

Contributors

darcyjoven avatar

Watchers

 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.