Skip to content

Commit

Permalink
Modifications to get an actual Go module
Browse files Browse the repository at this point in the history
Signed-off-by: Geoffroy Vallee <[email protected]>
  • Loading branch information
gvallee committed Dec 16, 2019
1 parent c816869 commit 4b32493
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 38 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/go.yml
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

3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/gvallee/syserror

go 1.12
40 changes: 40 additions & 0 deletions pkg/syserror/syserror.go
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.
38 changes: 0 additions & 38 deletions syserror.go

This file was deleted.

0 comments on commit 4b32493

Please sign in to comment.