golib

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2018 License: MIT Imports: 17 Imported by: 2

README

Utility library for Golang

Overview

Golangの共通ライブラリとして処理をまとめてあります。
現在は以下のようなことができます。

  1. 設定ファイルをJSONより読み込み、構造体に保持
  2. ログ出力をレベル分けして出力
  3. メール送信

Requirements

  • Golang 1.8+

Setup

以下コマンドで$GOPATHにインストールされます。

$ go get -u github.com/gotoeveryone/golib

Run

config.json.exampleを参考に、任意ディレクトリに「config.json」を作成してください。
※値は実際に利用するサービスの接続情報を設定すること。

以下コマンドで実行時、設定ファイルの格納ディレクトリを示す--confオプションで対象ディレクトリを指定してください。
未指定の場合は実行ファイルと同じディレクトリを参照します。

$ go run <my_program> --conf=/path/to/

Test

$ cd <this_directory>
$ go test

Documentation

Index

Constants

View Source
const (

	// LevelDebug is debug level text
	LevelDebug = "DEBUG"
	// LevelInfo is info level text
	LevelInfo = "INFO"
	// LevelWarning is warning level text
	LevelWarning = "WARNING"
	// LevelError is error level text
	LevelError = "ERROR"
)

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(config interface{}, customPath string) error

LoadConfig is read the configuration from the JSON file into the structure

func SendMail

func SendMail(c config.Mail, subject string, body string) error

SendMail メール送信

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is logger with configuration.

func NewLogger

func NewLogger(c config.Log) (*Logger, error)

NewLogger is logger with prefix.

func (*Logger) Debug

func (l *Logger) Debug(v interface{})

Debug is debug level logging

func (*Logger) Error

func (l *Logger) Error(v interface{})

Error is error level logging

func (*Logger) Info

func (l *Logger) Info(v interface{})

Info is info level logging

func (*Logger) Level

func (l *Logger) Level() config.LogLevel

Level is return log level

func (*Logger) Warning

func (l *Logger) Warning(v interface{})

Warning is info level logging

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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