https://github.com/s8sg/goshnix
A powerful Golang Stdlib over SSH for UNIX
https://github.com/s8sg/goshnix
golang-library goshnix-client ssh
Last synced: over 1 year ago
JSON representation
A powerful Golang Stdlib over SSH for UNIX
- Host: GitHub
- URL: https://github.com/s8sg/goshnix
- Owner: s8sg
- License: mit
- Created: 2016-03-02T07:33:51.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-07T09:15:39.000Z (over 10 years ago)
- Last Synced: 2025-03-20T02:08:07.778Z (over 1 year ago)
- Topics: golang-library, goshnix-client, ssh
- Language: Go
- Homepage:
- Size: 150 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goshnix
.png)
A powerful UNIX utility for performing Golang API over SSH. It abstracts the underlying method for Goshnix supported API, so that your program logic stays same
[](https://godoc.org/github.com/swarvanusg/goshnix)
### Version
1.0.0
### Get It
```go
go get github.com/swarvanusg/goshnix
```
### Use it
##### Initiate Goshnix Client
```go
goshclient, err := goshnix.Init("", "", "", "")
```
##### Use Goshnix Client as a Std Lib
Check you environment variable
```go
envval, err := goshclient.Getenv("")
```
Get a file stat
```go
fileinfo, _ := goshclient.Stat("")
// Check if its a dir (as of std lib)
if fileinfo.IsDir() {
// ...
}
```
Get the list of directory entries
```go
var fileinfos []os.FileInfo
fileinfos, _ := goshclient.ReadDir("")
```
For full listing of supported API see the godoc.
##### Use Goshnix API to Understand Error
Goshnix returned error could be communication error as well as command execution error. Goshnix provides API to understand proper error sub-type
```go
filecontent, err := goshclient.ReadFile(filename string)
if err != nil {
// Check error type
switch {
case Isssherror(err):
// ssh error handling logic
case Iscmderror(err):
// cmd error handling logic
}
}
```
### How it works
For each of the API, one or multiple UNIX commands gets executed over ssh to the targeted host.
### License
MIT