Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-25 00:39:14 -06:00
parent e24c2c2eb3
commit 41fe4a4659
20 changed files with 187 additions and 203 deletions

View File

@ -1,32 +1,9 @@
all: all:
# 'gaper' is a simple and smart golang tool that just rebuilds every time you change a file
# go get -u github.com/maxcnunes/gaper
# gaper
# simple sortcut to push all git changes goimports:
push: goimports -w *.go
git pull
git add --all
-git commit -a -s
git push
redomod: redomod:
rm -f go.* rm -f go.*
unset GO111MODULES && go mod init GO111MODULE= go mod init
unset GO111MODULES && go mod tidy GO111MODULE= go mod tidy
# should update every go dependancy (?)
update:
git pull
go get -v -t -u ./...
# sync repo to the github backup
# git remote add github2 git@github.com:wit-go/shell.git
# git branch -M master
github:
git push origin master
git push origin devel
git push origin --tags
git push github master
git push github devel
git push github --tags

View File

@ -8,7 +8,7 @@ non-blocking unbuffered way
# install # install
``` ```
go get -v -t -u go.wit.com/shell go get -v -t -u go.wit.com/lib/gui/shell
``` ```
# License # License

View File

@ -12,7 +12,7 @@ var RUN *log.LogFlag
var SSH *log.LogFlag var SSH *log.LogFlag
func init() { func init() {
full := "go.wit.com/shell" full := "go.wit.com/lib/gui/shell"
short := "shell" short := "shell"
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff") NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")

View File

@ -7,10 +7,10 @@ package shell
*/ */
import ( import (
"bytes"
"fmt" "fmt"
"reflect" "reflect"
"strings" "strings"
"bytes"
"go.wit.com/log" "go.wit.com/log"
) )
@ -24,14 +24,12 @@ func chompBytesBuffer(buf *bytes.Buffer) string {
return Chomp(string(bytesSplice)) return Chomp(string(bytesSplice))
} }
//
// TODO: obviously this is stupidly wrong // TODO: obviously this is stupidly wrong
// TODO: fix this to trim fucking everything // TODO: fix this to trim fucking everything
// really world? 8 fucking years of this language // really world? 8 fucking years of this language
// and I'm fucking writing this? jesus. how the // and I'm fucking writing this? jesus. how the
// hell is everyone else doing this? Why isn't // hell is everyone else doing this? Why isn't
// this already in the strings package? // this already in the strings package?
//
func perlChomp(s string) string { func perlChomp(s string) string {
// lots of stuff in go moves around the whole block of whatever it is so lots of things are padded with NULL values // lots of stuff in go moves around the whole block of whatever it is so lots of things are padded with NULL values
s = strings.Trim(s, "\x00") // removes NULL (needed!) s = strings.Trim(s, "\x00") // removes NULL (needed!)
@ -74,7 +72,7 @@ func Chomp(a interface{}) string {
// log.Printf("shell.Chomp() FOUND *bytes.Buffer") // log.Printf("shell.Chomp() FOUND *bytes.Buffer")
var tmp *bytes.Buffer var tmp *bytes.Buffer
tmp = a.(*bytes.Buffer) tmp = a.(*bytes.Buffer)
if (tmp == nil) { if tmp == nil {
return "" return ""
} }

View File

@ -1,3 +1,11 @@
all: all:
# go build # go build
GO111MODULE="off" go run main.go GO111MODULE="off" go run main.go
goimports:
goimports -w *.go
redomod:
rm -f go.*
GO111MODULE= go mod init
GO111MODULE= go mod tidy

3
example1/go.mod Normal file
View File

@ -0,0 +1,3 @@
module go.wit.com/lib/gui/shell/example1
go 1.21.4

View File

@ -9,7 +9,7 @@ import "os"
// import "github.com/davecgh/go-spew/spew" // import "github.com/davecgh/go-spew/spew"
import "go.wit.com/shell" import "go.wit.com/lib/gui/shell"
func main() { func main() {
shell.Run("ls /tmp") shell.Run("ls /tmp")

View File

@ -2,7 +2,7 @@ package main
import "log" import "log"
// import "fmt" // import "fmt"
import "go.wit.com/shell" import "go.wit.com/lib/gui/shell"
func main() { func main() {
err := shell.Run("cat /etc/issue") err := shell.Run("cat /etc/issue")

10
go.mod
View File

@ -1,4 +1,4 @@
module go.wit.com/shell module go.wit.com/lib/gui/shell
go 1.21.4 go 1.21.4
@ -6,14 +6,14 @@ require (
github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
go.wit.com/log v0.4.1 go.wit.com/log v0.5.6
golang.org/x/crypto v0.17.0 golang.org/x/crypto v0.18.0
) )
require ( require (
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 // indirect go.wit.com/dev/davecgh/spew v1.1.4 // indirect
golang.org/x/sys v0.15.0 // indirect golang.org/x/sys v0.16.0 // indirect
) )

20
go.sum
View File

@ -18,17 +18,17 @@ github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef h1:7D6Nm4D6f0ci9yttWaKjM1T
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef/go.mod h1:WLFStEdnJXpjK8kd4qKLwQKX/1vrDzp5BcDyiZJBHJM= github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef/go.mod h1:WLFStEdnJXpjK8kd4qKLwQKX/1vrDzp5BcDyiZJBHJM=
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 h1:67A5tweHp3C7osHjrYsy6pQZ00bYkTTttZ7kiOwwHeA= github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 h1:67A5tweHp3C7osHjrYsy6pQZ00bYkTTttZ7kiOwwHeA=
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg= github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg=
go.wit.com/log v0.4.1 h1:x2PXlm1exgFrweGTM7thyj6KJabtnGlXssYkxv56hpc= go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
go.wit.com/log v0.4.1/go.mod h1:EZLvivLZpMoXl5AUBArH0zsIgr+c+WyNXm14BCF+sdw= go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 h1:UEX2EzLQPzLTfy/kUFQD7OXtvKn8wk/+jpDOkbl4ff4= go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9/go.mod h1:qBpgJXThMMT15vym7/E4Ur9y8oOo2nP7t2RP52QHUNw= go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

4
int.go
View File

@ -13,7 +13,7 @@ import "strconv"
func Int(s string) int { func Int(s string) int {
s = Chomp(s) s = Chomp(s)
i, err := strconv.Atoi(s) i, err := strconv.Atoi(s)
if (err != nil) { if err != nil {
handleError(err, -1) handleError(err, -1)
return 0 return 0
} }
@ -23,7 +23,7 @@ func Int(s string) int {
func Int64(s string) int64 { func Int64(s string) int64 {
s = Chomp(s) s = Chomp(s)
i, err := strconv.Atoi(s) i, err := strconv.Atoi(s)
if (err != nil) { if err != nil {
handleError(err, -1) handleError(err, -1)
return 0 return 0
} }

View File

@ -1,22 +1,18 @@
//go:build linux && go1.7
// +build linux,go1.7 // +build linux,go1.7
// put stuff in here that you only want compiled under linux // put stuff in here that you only want compiled under linux
package shell package shell
import "log" import (
import "os" "log"
import "os/signal" "os"
import "syscall" "os/signal"
"syscall"
// import "runtime" "github.com/wercker/journalhook"
// import "time" )
// import "reflect"
// import "go.wit.com/shell"
// import "github.com/davecgh/go-spew/spew"
import "github.com/wercker/journalhook"
var sigChan chan os.Signal var sigChan chan os.Signal

View File

@ -1,10 +1,12 @@
package shell package shell
import "crypto/md5" import (
import "encoding/hex" "crypto/md5"
import "log" "encoding/hex"
import "io" "io"
import "os" "log"
"os"
)
func hash_file_md5(filePath string) (string, error) { func hash_file_md5(filePath string) (string, error) {
var returnMD5String string var returnMD5String string

42
run.go
View File

@ -1,14 +1,14 @@
package shell package shell
import ( import (
"bufio"
"bytes"
"fmt"
"io"
"os"
"os/exec"
"strings" "strings"
"time" "time"
"os/exec"
"bytes"
"io"
"fmt"
"os"
"bufio"
"github.com/svent/go-nbreader" "github.com/svent/go-nbreader"
@ -31,7 +31,7 @@ func Run(cmdline string) string {
func (cmd *Shell) Run(cmdline string) string { func (cmd *Shell) Run(cmdline string) string {
cmd.InitProcess(cmdline) cmd.InitProcess(cmdline)
if (cmd.Error != nil) { if cmd.Error != nil {
return "" return ""
} }
cmd.Exec(cmdline) cmd.Exec(cmdline)
@ -43,13 +43,13 @@ func (cmd *Shell) InitProcess(cmdline string) {
cmd.Cmdline = Chomp(cmdline) // this is like 'chomp' in perl cmd.Cmdline = Chomp(cmdline) // this is like 'chomp' in perl
cmdArgs := strings.Fields(cmd.Cmdline) cmdArgs := strings.Fields(cmd.Cmdline)
if (len(cmdArgs) == 0) { if len(cmdArgs) == 0 {
cmd.Error = fmt.Errorf("cmdline == ''") cmd.Error = fmt.Errorf("cmdline == ''")
cmd.Done = true cmd.Done = true
return return
} }
if (cmdArgs[0] == "cd") { if cmdArgs[0] == "cd" {
if (len(cmdArgs) > 1) { if len(cmdArgs) > 1 {
log.Log(RUN, "os.Chdir()", cmd) log.Log(RUN, "os.Chdir()", cmd)
os.Chdir(cmdArgs[1]) os.Chdir(cmdArgs[1])
} }
@ -65,7 +65,7 @@ func (cmd *Shell) FileCreate(out string) {
var newfile File var newfile File
var iof io.ReadCloser var iof io.ReadCloser
if (out == "STDOUT") { if out == "STDOUT" {
iof, _ = cmd.Process.StdoutPipe() iof, _ = cmd.Process.StdoutPipe()
} else { } else {
iof, _ = cmd.Process.StderrPipe() iof, _ = cmd.Process.StderrPipe()
@ -75,7 +75,7 @@ func (cmd *Shell) FileCreate(out string) {
newfile.Fbufio = bufio.NewReader(iof) newfile.Fbufio = bufio.NewReader(iof)
newfile.Fnbreader = nbreader.NewNBReader(newfile.Fbufio, 1024) newfile.Fnbreader = nbreader.NewNBReader(newfile.Fbufio, 1024)
if (out == "STDOUT") { if out == "STDOUT" {
cmd.STDOUT = &newfile cmd.STDOUT = &newfile
} else { } else {
cmd.STDERR = &newfile cmd.STDERR = &newfile
@ -88,7 +88,7 @@ func (cmd *Shell) Exec(cmdline string) {
log.Log(RUN, "shell.Run() START "+cmdline) log.Log(RUN, "shell.Run() START "+cmdline)
cmd.InitProcess(cmdline) cmd.InitProcess(cmdline)
if (cmd.Error != nil) { if cmd.Error != nil {
return return
} }
@ -111,7 +111,7 @@ func (cmd *Shell) Exec(cmdline string) {
// time.Sleep(2 * time.Second) // putting this here doesn't help STDOUT flush() // time.Sleep(2 * time.Second) // putting this here doesn't help STDOUT flush()
if (err != nil) { if err != nil {
cmd.Fail = true cmd.Fail = true
cmd.Error = err cmd.Error = err
log.Log(RUN, "process.Wait() END err =", err.Error()) log.Log(RUN, "process.Wait() END err =", err.Error())
@ -125,10 +125,10 @@ func (cmd *Shell) Exec(cmdline string) {
func (cmd *Shell) Capture(f *File) { func (cmd *Shell) Capture(f *File) {
log.Log(RUN, "nbrREADER() START") log.Log(RUN, "nbrREADER() START")
if (cmd.Buffer == nil) { if cmd.Buffer == nil {
cmd.Buffer = new(bytes.Buffer) cmd.Buffer = new(bytes.Buffer)
} }
if (cmd.Buffer == nil) { if cmd.Buffer == nil {
f.Dead = false f.Dead = false
cmd.Error = fmt.Errorf("could not make buffer") cmd.Error = fmt.Errorf("could not make buffer")
log.Error(cmd.Error, "f.Buffer == nil") log.Error(cmd.Error, "f.Buffer == nil")
@ -139,7 +139,7 @@ func (cmd *Shell) Capture(f *File) {
f.Dead = false f.Dead = false
// loop that keeps trying to read from f // loop that keeps trying to read from f
for (f.Dead == false) { for f.Dead == false {
time.Sleep(time.Duration(msecDelay) * time.Millisecond) // only check the buffer 500 times a second time.Sleep(time.Duration(msecDelay) * time.Millisecond) // only check the buffer 500 times a second
// set to false so it keeps retrying reads // set to false so it keeps retrying reads
@ -147,7 +147,7 @@ func (cmd *Shell) Capture(f *File) {
// tight loop that reads 1024 bytes at a time until buffer is empty // tight loop that reads 1024 bytes at a time until buffer is empty
// 1024 is set in f.BufferSize // 1024 is set in f.BufferSize
for (f.Empty == false) { for f.Empty == false {
f.Empty = cmd.ReadToBuffer(f) f.Empty = cmd.ReadToBuffer(f)
} }
} }
@ -158,7 +158,7 @@ func (cmd *Shell) ReadToBuffer(f *File) bool {
log.Log(RUN, "ReadToBuffer() START") log.Log(RUN, "ReadToBuffer() START")
nbr := f.Fnbreader nbr := f.Fnbreader
oneByte := make([]byte, 1024) oneByte := make([]byte, 1024)
if (nbr == nil) { if nbr == nil {
// log.Debugln("ReadToBuffer() ERROR nbr is nil") // log.Debugln("ReadToBuffer() ERROR nbr is nil")
f.Dead = true f.Dead = true
return true return true
@ -166,13 +166,13 @@ func (cmd *Shell) ReadToBuffer(f *File) bool {
count, err := nbr.Read(oneByte) count, err := nbr.Read(oneByte)
f.TotalCount += count f.TotalCount += count
if (err != nil) { if err != nil {
// log.Debugln("ReadToBuffer() file has closed with", err) // log.Debugln("ReadToBuffer() file has closed with", err)
// log.Debugln("ReadToBuffer() count = ", count, "err = ", err) // log.Debugln("ReadToBuffer() count = ", count, "err = ", err)
f.Dead = true f.Dead = true
return true return true
} }
if (count == 0) { if count == 0 {
// log.Debugln("ReadToBuffer() START count == 0 return true") // log.Debugln("ReadToBuffer() START count == 0 return true")
return true return true
} }

View File

@ -1,18 +1,17 @@
package shell package shell
import ( import (
"strings"
"time"
"os"
"os/exec"
"bufio" "bufio"
"io/ioutil" "io/ioutil"
"os"
"os/exec"
"strings"
"time"
"go.wit.com/log"
"github.com/svent/go-nbreader" "github.com/svent/go-nbreader"
"go.wit.com/log"
) )
// TODO: look at https://github.com/go-cmd/cmd/issues/20 // TODO: look at https://github.com/go-cmd/cmd/issues/20
// use go-cmd instead here? // use go-cmd instead here?
@ -23,6 +22,7 @@ var shellStderr *os.File
var spewOn bool = false var spewOn bool = false
var quiet bool = false var quiet bool = false
// var msecDelay int = 20 // number of milliseconds to delay between reads with no data // var msecDelay int = 20 // number of milliseconds to delay between reads with no data
// var bytesBuffer bytes.Buffer // var bytesBuffer bytes.Buffer
@ -30,7 +30,7 @@ var quiet bool = false
func handleError(c interface{}, ret int) { func handleError(c interface{}, ret int) {
log.Log(INFO, "shell.Run() Returned", ret) log.Log(INFO, "shell.Run() Returned", ret)
if (callback != nil) { if callback != nil {
callback(c, ret) callback(c, ret)
} }
} }
@ -122,22 +122,22 @@ func nonBlockingReader(buffReader *bufio.Reader, writeFileHandle *os.File, stdou
for { for {
oneByte := make([]byte, 1024) oneByte := make([]byte, 1024)
count, err := nbr.Read(oneByte) count, err := nbr.Read(oneByte)
if (err != nil) { if err != nil {
log.Log(INFO, "count, err =", count, err) log.Log(INFO, "count, err =", count, err)
handleError(err, -1) handleError(err, -1)
return return
} }
totalCount += count totalCount += count
if (count == 0) { if count == 0 {
time.Sleep(time.Duration(msecDelay) * time.Millisecond) // without this delay this will peg the CPU time.Sleep(time.Duration(msecDelay) * time.Millisecond) // without this delay this will peg the CPU
if (totalCount != 0) { if totalCount != 0 {
log.Log(INFO, "STDERR: totalCount = ", totalCount) log.Log(INFO, "STDERR: totalCount = ", totalCount)
totalCount = 0 totalCount = 0
} }
} else { } else {
log.Log(INFO, "STDERR: count = ", count) log.Log(INFO, "STDERR: count = ", count)
writeFileHandle.Write(oneByte[0:count]) writeFileHandle.Write(oneByte[0:count])
if (quiet == false) { if quiet == false {
stdout.Write(oneByte[0:count]) stdout.Write(oneByte[0:count])
stdout.Flush() stdout.Flush()
} }

4
ssh.go
View File

@ -5,9 +5,9 @@ import (
"io/ioutil" "io/ioutil"
"time" "time"
"golang.org/x/crypto/ssh"
"github.com/tmc/scp" "github.com/tmc/scp"
"go.wit.com/log" "go.wit.com/log"
"golang.org/x/crypto/ssh"
) )
var sshHostname string var sshHostname string
@ -49,7 +49,7 @@ func mySsh(hostname string, port int, username string, pass string, keyfile stri
// log.Log(SSH, "hostkey =", hostKey) // log.Log(SSH, "hostkey =", hostKey)
publicKey, err := PublicKeyFile(keyfile) publicKey, err := PublicKeyFile(keyfile)
if (err != nil) { if err != nil {
log.Log(SSH, "PublicKeyFile() error =", err) log.Log(SSH, "PublicKeyFile() error =", err)
} }

View File

@ -1,10 +1,13 @@
package shell package shell
import "io" import (
import "os/exec" "bufio"
import "bufio" "bytes"
import "bytes" "io"
import "github.com/svent/go-nbreader" "os/exec"
"github.com/svent/go-nbreader"
)
var FileMap map[string]*File var FileMap map[string]*File

13
wget.go
View File

@ -11,17 +11,17 @@ package shell
*/ */
import ( import (
"io"
"os"
"fmt"
"bytes" "bytes"
"strings" "fmt"
"io"
"net/http" "net/http"
"os"
"strings"
"go.wit.com/log" "go.wit.com/log"
) )
func Wget(url string) (*bytes.Buffer) { func Wget(url string) *bytes.Buffer {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
// Get the data // Get the data
@ -33,7 +33,7 @@ func Wget(url string) (*bytes.Buffer) {
defer resp.Body.Close() defer resp.Body.Close()
log.Log(INFO, "res.StatusCode: %d\n", resp.StatusCode) log.Log(INFO, "res.StatusCode: %d\n", resp.StatusCode)
if (resp.StatusCode != 200) { if resp.StatusCode != 200 {
handleError(fmt.Errorf(fmt.Sprint("%d", resp.StatusCode)), -1) handleError(fmt.Errorf(fmt.Sprint("%d", resp.StatusCode)), -1)
return nil return nil
} }
@ -72,7 +72,6 @@ func WgetToFile(filepath string, url string) error {
// package. I will quote the evilwm man page: // package. I will quote the evilwm man page:
// //
// BUGS: The author's idea of friendly may differ to that of many other people. // BUGS: The author's idea of friendly may differ to that of many other people.
//
func Write(filepath string, data string) bool { func Write(filepath string, data string) bool {
// TODO: this isn't working for some reason and is making two '\n' chars // TODO: this isn't working for some reason and is making two '\n' chars
// probably because Chomp() isn't fixed yet // probably because Chomp() isn't fixed yet

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
// put stuff in here that you only want compiled under windows // put stuff in here that you only want compiled under windows
@ -8,9 +9,6 @@ import (
"go.wit.com/log" "go.wit.com/log"
) )
// import "go.wit.com/shell"
// import "github.com/davecgh/go-spew/spew"
func handleSignal(err interface{}, ret int) { func handleSignal(err interface{}, ret int) {
log.Warn("handleSignal() windows doesn't do signals") log.Warn("handleSignal() windows doesn't do signals")
} }