Skip to content

Instantly share code, notes, and snippets.

@budougumi0617
Created August 28, 2019 01:29
Show Gist options
  • Save budougumi0617/c7d55ca3a3d239309afaed11cc5c14d4 to your computer and use it in GitHub Desktop.
Save budougumi0617/c7d55ca3a3d239309afaed11cc5c14d4 to your computer and use it in GitHub Desktop.
fix go.mod error
module github.com/skanehira/docui
go 1.12
require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/Sirupsen/logrus v1.4.2
github.com/docker/distribution v2.7.1+incompatible // indirect
// v17.05.0-ce
github.com/docker/docker v0.0.0-20170504205632-89658bed64c2
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.4.0 // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/gdamore/tcell v1.2.0
github.com/jroimartin/gocui v0.4.0
github.com/micmonay/keybd_event v0.0.0-20190804163414-202c5b2c8150
github.com/mitchellh/go-homedir v1.1.0
github.com/nsf/termbox-go v0.0.0-20190817171036-93860e161317 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/rivo/tview v0.0.0-20190721135419-23dc8a0944e4
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
)
replace github.com/Sirupsen/logrus v1.4.2 => github.com/sirupsen/logrus v1.4.2
// common/logger.go
package common
import (
"os"
"path/filepath"
log "github.com/Sirupsen/logrus"
homedir "github.com/mitchellh/go-homedir"
)
// Logger logger
var Logger *logger
// Logger logger.
type logger struct {
*os.File
*log.Logger
}
// NewLogger create new logger.
func NewLogger(logLevel string) {
level, err := log.ParseLevel(logLevel)
if err != nil {
panic(err)
}
home, err := homedir.Dir()
if err != nil {
panic(err)
}
logFile, err := os.OpenFile(filepath.Join(home, "docui.log"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
panic(err)
}
log.SetFormatter(&log.TextFormatter{
DisableColors: true,
FullTimestamp: true,
})
log.SetOutput(logFile)
log.SetLevel(level)
log.SetReportCaller(true)
Logger = &logger{
File: logFile,
Logger: log.StandardLogger(),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment