提交 98d82554 编写于 作者: 李光春's avatar 李光春

init

上级
# 使用vendor文件夹构建
export GO15VENDOREXPERIMENT=1
export GOPROXY=https://goproxy.cn,direct
# 在工作目录创建源文件夹
mkdir -p $GOPATH/src/dtapps/golang/
# 拷贝代码到创建好的目录
cp -rf . $GOPATH/src/dtapps/golang/
# 进入项目
cd $GOPATH/src/dtapps/golang/
# 构建,在GOPATH下生成构建包
go mod tidy
# 列出文件
ls -lh
\ No newline at end of file
kind: pipeline
type: docker # 使用docker
name: default
steps:
- name: go-library
image: golang
commands:
- go mod tidy
- ls -lh
.env
.git
.svn
.idea
.vscode
*.log
git.sh
gittag.sh
gitinit.sh
config.yaml
\ No newline at end of file
language: go
go:
- master
script:
- go mod tidy
- ls -lh
\ No newline at end of file
## v1.0.0 / 2021-06-26
- Golang 日志
\ No newline at end of file
MIT License
Copyright (c) 2021 李光春
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
<img width="100" src="https://kodo-cdn.dtapp.net/04/999e9f2f06d396968eacc10ce9bc8a.png" alt="www.dtapp.net"/>
<h1><a href="https://www.dtapp.net/">Golang Log</a></h1>
📦 Golang 日志
[comment]: <> (dtapps)
![GitHub Org's stars](https://img.shields.io/github/stars/dtapps?style=for-the-badge)
[comment]: <> (go)
![golang version](https://img.shields.io/badge/golang-%3E%3D1.6-8892BF.svg?style=for-the-badge)
![godoc](https://pkg.go.dev/badge/github.com/dtapps/go-log?status.svg)
[comment]: <> (goproxy.cn)
![goproxy](https://goproxy.cn/stats/github.com/dtapps/go-log/badges/download-count.svg)
[comment]: <> (goreportcard.com)
![go report card](https://goreportcard.com/badge/github.com/dtapps/go-log)
[comment]: <> (badge.fury.io)
![go project version](https://badge.fury.io/go/github.com%2Fdtapps%2Fgo-log.svg)
[comment]: <> (github.com)
![latest release](https://badgen.net/github/release/dtapps/go-log)
![latest stable release](https://badgen.net/github/release/dtapps/go-log/stable)
![latest tag](https://badgen.net/github/tag/dtapps/go-log)
![watchers](https://badgen.net/github/watchers/dtapps/go-log)
![combined checks (master branch)](https://badgen.net/github/checks/dtapps/go-log)
![stars](https://badgen.net/github/stars/dtapps/go-log)
![forks](https://badgen.net/github/forks/dtapps/go-log)
![issues](https://badgen.net/github/issues/dtapps/go-log)
![branches](https://badgen.net/github/branches/dtapps/go-log)
![releases](https://badgen.net/github/releases/dtapps/go-log)
![tags](https://badgen.net/github/tags/dtapps/go-log)
![license](https://badgen.net/github/license/dtapps/go-log)
![contributors](https://badgen.net/github/contributors/dtapps/go-log)
![assets downloads for latest release](https://badgen.net/github/assets-dl/dtapps/go-log)
![assets downloads for a tag](https://badgen.net/github/assets-dl/dtapps/go-log/1.0.11)
![repository dependents](https://badgen.net/github/dependents-repo/dtapps/go-log)
![package dependents](https://badgen.net/github/dependents-pkg/dtapps/go-log)
![dependabot status](https://badgen.net/github/dependabot/dtapps/go-log)
![GitHub last commit](https://img.shields.io/github/last-commit/dtapps/go-log?style=for-the-badge)
![GitHub commit activity](https://img.shields.io/github/commit-activity/w/dtapps/go-log?style=for-the-badge)
![Github All Contributors](https://img.shields.io/github/all-contributors/dtapps/go-log/master?style=for-the-badge)
![GitHub go.mod Go version (branch)](https://img.shields.io/github/go-mod/go-version/dtapps/go-version/master?style=for-the-badge)
![GitHub go.mod Go version (subdirectory of monorepo)](https://img.shields.io/github/go-mod/go-version/dtapps/go-log?style=for-the-badge)
![GitHub go.mod Go version (branch & subdirectory of monorepo)](https://img.shields.io/github/go-mod/go-version/dtapps/go-log/master?style=for-the-badge)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/dtapps/go-log?style=for-the-badge)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/dtapps/go-log?style=for-the-badge)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/dtapps/go-log?style=for-the-badge)
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/dtapps/go-log?style=for-the-badge)
![GitHub pull requests](https://img.shields.io/github/issues-pr/dtapps/go-log?style=for-the-badge)
![GitHub issues](https://img.shields.io/github/issues/dtapps/go-log?style=for-the-badge)
![GitHub Sponsors](https://img.shields.io/github/sponsors/dtapps?style=for-the-badge)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/dtapps/go-log?style=for-the-badge)
![GitHub language count](https://img.shields.io/github/languages/count/dtapps/go-log?style=for-the-badge)
![GitHub search hit counter](https://img.shields.io/github/search/dtapps/go-log/go?style=for-the-badge)
![GitHub top language](https://img.shields.io/github/languages/top/dtapps/go-log?style=for-the-badge)
[comment]: <> (scrutinizer-ci.com)
![Scrutinizer build (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/build/g/dtapps/go-log/master?style=for-the-badge)
![Scrutinizer coverage (GitHub/BitBucket)](https://img.shields.io/scrutinizer/coverage/g/dtapps/go-log/master?style=for-the-badge)
![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/dtapps/go-log/master?style=for-the-badge)
[comment]: <> (www.travis-ci.com)
![Travis (.com) branch](https://img.shields.io/travis/com/dtapps/go-log/master?style=for-the-badge)
[comment]: <> (app.codecov.io)
![Codecov branch](https://img.shields.io/codecov/c/github/dtapps/go-log/master?style=for-the-badge)
## 安装
```go
go get -u github.com/dtapps/go-log
```
\ No newline at end of file
package main
import (
"log"
"os"
"time"
)
func init() {
getDir, _ := os.Getwd()
// 判断文件夹
logStatus, _ := existFiles(getDir + "log/")
if logStatus == false {
_, _ = createFiles(getDir+"log/", 0755)
}
}
func Info(accessLog string) {
if f, err := os.OpenFile("log/"+getCurrentWjDate()+".log", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666); err != nil {
log.Println(err)
} else {
_, _ = f.WriteString(accessLog + "\n")
}
}
func getCurrentWjDate() string {
return time.Now().Format("20060102")
}
func existFiles(path string) (bool, error) {
_, err := os.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
}
func createFiles(path string, perm int) (bool, error) {
err := os.MkdirAll(path, os.FileMode(perm))
if err != nil {
return false, err
} else {
return true, nil
}
}
package main
import "testing"
func TestName(t *testing.T) {
Info("sb")
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册