initial commits

master
Charles Iliya Krempeaux 2021-11-19 15:41:30 -08:00
commit 70207f8e01
5 changed files with 67 additions and 0 deletions

19
LICENSE 100644
View File

@ -0,0 +1,19 @@
Copyright (c) 2021 Charles Iliya Krempeaux :: http://changelog.ca/
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.

24
README.md 100644
View File

@ -0,0 +1,24 @@
# go-fck
Package **fck** implements tools to create and manipulate errors.
## Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-fck
[![GoDoc](https://godoc.org/github.com/reiver/go-fck?status.svg)](https://godoc.org/github.com/reiver/go-fck)
## Creating Errors
There are two ways to create errors —
With `fck.Error`:
```
const err error = fck.Error("internal-error")
```
And with `fck.Errorf`:
```
const err error = fck.Errorf("bad value for id %q", id)
```
**One thing to notice is that `fck.Error` errors can be a Go `const`.**

9
error.go 100644
View File

@ -0,0 +1,9 @@
package fck
type Error string
func (receiver Error) Error() string {
return string(receiver)
}
var _ error = Error("")

12
errorf.go 100644
View File

@ -0,0 +1,12 @@
package fck
import (
"fmt"
)
func Errorf(format string, a ...interface{}) error {
var s string =fmt.Sprintf(format, a...)
return Error(s)
}

3
go.mod 100644
View File

@ -0,0 +1,3 @@
module github.com/reiver/go-fck
go 1.17