More Code-Style

This commit is contained in:
darmiel 2021-05-16 23:22:36 +02:00
parent c1ffda6138
commit 4b7a7e55d7
3 changed files with 7 additions and 3 deletions

View file

@ -1,3 +1,7 @@
[![Deploy to docker hub (v-tag)](https://github.com/darmiel/yaxc/actions/workflows/deploy_hub.yml/badge.svg)](https://github.com/darmiel/yaxc/actions/workflows/deploy_hub.yml) |
[![.github/workflows/test.yml](https://github.com/darmiel/yaxc/actions/workflows/test.yml/badge.svg)](https://github.com/darmiel/yaxc/actions/workflows/test.yml) |
[![DeepSource](https://deepsource.io/gh/darmiel/yaxc.svg/?label=active+issues&show_trend=true)](https://deepsource.io/gh/darmiel/yaxc/?ref=repository-badge)
<!-- Logo -->
<p align="center">
<img src="./assets/YAxC-Filled@128px.png" alt="yaxc">

View file

@ -36,7 +36,7 @@ var pasteCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
// Read pipe
pipe, err := common.ReadPipe()
if err == common.NotPiped {
if err == common.ErrNotPiped {
log.Fatalln("The command is intended to work with pipes.")
return
}

View file

@ -8,7 +8,7 @@ import (
"strings"
)
var NotPiped = errors.New("not piped")
var ErrNotPiped = errors.New("not piped")
func ReadPipe() (res string, err error) {
var info os.FileInfo
@ -16,7 +16,7 @@ func ReadPipe() (res string, err error) {
return
}
if info.Mode()&os.ModeCharDevice != 0 || info.Size() <= 0 {
err = NotPiped
err = ErrNotPiped
return
}
reader := bufio.NewReader(os.Stdin)