Project has been created
This commit is contained in:
commit
461c681407
68
.gitignore
vendored
Normal file
68
.gitignore
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff:
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
|
||||||
|
# Sensitive or high-churn files:
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.xml
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
|
||||||
|
# Gradle:
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Mongo Explorer plugin:
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
## File-based project format:
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
### Go template
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Test binary, build with `go test -c`
|
||||||
|
*.test
|
||||||
|
|
||||||
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
|
*.out
|
||||||
|
|
||||||
|
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||||
|
.glide/
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
vendor/
|
||||||
|
glide.lock
|
||||||
|
.DS_Store
|
||||||
|
dist/
|
||||||
|
debug
|
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "debug",
|
||||||
|
"remotePath": "",
|
||||||
|
"port": 2345,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"program": "${workspaceRoot}/main.go",
|
||||||
|
"env": {},
|
||||||
|
"args": [],
|
||||||
|
"showLog": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "File Debug",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "debug",
|
||||||
|
"remotePath": "",
|
||||||
|
"port": 2345,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"program": "${fileDirname}",
|
||||||
|
"env": {},
|
||||||
|
"args": [],
|
||||||
|
"showLog": true
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
11
.vscode/settings.json
vendored
Normal file
11
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
// Specifies Lint tool name.
|
||||||
|
"go.lintTool": "gometalinter",
|
||||||
|
|
||||||
|
// Flags to pass to Lint tool (e.g. ["-min_confidence=.8"])
|
||||||
|
"go.lintFlags": [
|
||||||
|
"--config=${workspaceRoot}/golint.json"
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
8
glide.yaml
Normal file
8
glide.yaml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package: git.loafle.net/commons_go/logging
|
||||||
|
import:
|
||||||
|
- package: github.com/uber-go/zap
|
||||||
|
- package: go.uber.org/zap
|
||||||
|
version: v1.5.0
|
||||||
|
subpackages:
|
||||||
|
- internal
|
||||||
|
- internal/bufferpool
|
39
golint.json
Normal file
39
golint.json
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"DisableAll": true,
|
||||||
|
"Enable": [
|
||||||
|
"aligncheck",
|
||||||
|
"deadcode",
|
||||||
|
"dupl",
|
||||||
|
"errcheck",
|
||||||
|
"gas",
|
||||||
|
"goconst",
|
||||||
|
"gocyclo",
|
||||||
|
"gofmt",
|
||||||
|
"goimports",
|
||||||
|
"golint",
|
||||||
|
"gotype",
|
||||||
|
"ineffassign",
|
||||||
|
"interfacer",
|
||||||
|
"lll",
|
||||||
|
"megacheck",
|
||||||
|
"misspell",
|
||||||
|
"structcheck",
|
||||||
|
"test",
|
||||||
|
"testify",
|
||||||
|
"unconvert",
|
||||||
|
"varcheck",
|
||||||
|
"vet",
|
||||||
|
"vetshadow"
|
||||||
|
],
|
||||||
|
"Aggregate": true,
|
||||||
|
"Concurrency": 16,
|
||||||
|
"Cyclo": 60,
|
||||||
|
"Deadline": "60s",
|
||||||
|
"DuplThreshold": 50,
|
||||||
|
"EnableGC": true,
|
||||||
|
"LineLength": 120,
|
||||||
|
"MinConfidence": 0.8,
|
||||||
|
"MinOccurrences": 3,
|
||||||
|
"MinConstLength": 3,
|
||||||
|
"Sort": ["severity"]
|
||||||
|
}
|
38
logging.go
Normal file
38
logging.go
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"github.com/uber-go/zap"
|
||||||
|
)
|
||||||
|
|
||||||
|
type loggerKeyType int
|
||||||
|
|
||||||
|
const loggerKey loggerKeyType = iota
|
||||||
|
|
||||||
|
var defaultLogger zap.Logger
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
defaultLogger = zap.New(
|
||||||
|
zap.NewJSONEncoder(zap.TimeFormatter(TimestampField)),
|
||||||
|
zap.Fields(zap.Int("pid", os.Getpid())),
|
||||||
|
zap.String("exe", path.Base(os.Args[0])),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewContext(ctx context.Context, fields ...zap.Field) context.Context {
|
||||||
|
return context.WithValue(ctx, loggerKey, WithContext(ctx).With(fields...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func WithContext(ctx context.Context) zap.Logger {
|
||||||
|
if ctx == nil {
|
||||||
|
return defaultLogger
|
||||||
|
}
|
||||||
|
if ctxLogger, ok := ctx.Value(loggerKey).(zap.Logger); ok {
|
||||||
|
return ctxLogger
|
||||||
|
} else {
|
||||||
|
return defaultLogger
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user