-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifications to get an actual Go module
Signed-off-by: Geoffroy Vallee <[email protected]>
- Loading branch information
Showing
5 changed files
with
76 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Go | ||
on: [push, pull_request] | ||
jobs: | ||
|
||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.12 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.12 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v1 | ||
|
||
- name: Get dependencies | ||
run: | | ||
go get -v -t -d ./... | ||
if [ -f Gopkg.toml ]; then | ||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
dep ensure | ||
fi | ||
- name: Build and test | ||
run: | | ||
go build ./... | ||
go test | ||
env: | ||
GOPATH: /tmp/go | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/gvallee/syserror | ||
|
||
go 1.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2019, Geoffroy Vallee, All rights reserved | ||
// Copyright (c) 2019, Sylabs Inc. All rights reserved. | ||
// This software is licensed under a 3-clause BSD license. Please consult the | ||
// LICENSE.md file distributed with the sources of this project regarding your | ||
// rights to use or distribute this software. | ||
|
||
package syserror | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type SysError struct { | ||
msg string // message associated to the error | ||
code int // error code | ||
} | ||
|
||
// Predefined errors | ||
var NoErr = SysError{"Success", 0} // Success | ||
var ErrFatal = SysError{"Fatal error", -1} // Generic fatal error | ||
var ErrOutOfRes = SysError{"Out of resources", -2} // Out of resources (e.g., out of memory) | ||
var ErrNotAvailable = SysError{"Not available", -3} // The target is not available (e.g., a file does not exist) | ||
var ErrDataOverflow = SysError{"Data overflow", -4} // Data overflow | ||
var ErrInvalidArg = SysError{"Invalid argument", -5} // Invalid function argument | ||
|
||
func (err *SysError) Error() string { | ||
if err.code != 0 { | ||
return fmt.Sprintf("ERROR: %d: %s", err.code, err.msg) | ||
} else { | ||
return fmt.Sprintf("%d: %s", err.code, err.msg) | ||
} | ||
} | ||
|
||
func (_error SysError) getMsg() string { | ||
return _error.msg | ||
} | ||
|
||
func (_error SysError) getCode() int { | ||
return _error.code | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.