add macOS support
This commit is contained in:
16
.idea/workspace.xml
generated
16
.idea/workspace.xml
generated
@@ -2,12 +2,12 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/tests/controller/main.go" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/tests/extract/main.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/api/proto/control.proto" beforeDir="false" afterPath="$PROJECT_DIR$/api/proto/control.proto" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/controller.go" beforeDir="false" afterPath="$PROJECT_DIR$/controller.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bindata.go" beforeDir="false" afterPath="$PROJECT_DIR$/bindata.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/iperf.go" beforeDir="false" afterPath="$PROJECT_DIR$/iperf.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -83,6 +83,15 @@
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="go build github.com/BGrewell/go-iperf/tests/extract" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||
<module name="go-iperf" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<kind value="PACKAGE" />
|
||||
<filePath value="$PROJECT_DIR$/tests/extract/main.go" />
|
||||
<package value="github.com/BGrewell/go-iperf/tests/extract" />
|
||||
<directory value="$PROJECT_DIR$" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="go build github.com/BGrewell/go-iperf/tests/server" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
|
||||
<module name="go-iperf" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
@@ -95,6 +104,7 @@
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Go Build.go build github.com/BGrewell/go-iperf/tests/controller" />
|
||||
<item itemvalue="Go Build.go build github.com/BGrewell/go-iperf/tests/extract" />
|
||||
<item itemvalue="Go Build.go build github.com/BGrewell/go-iperf/tests/client" />
|
||||
<item itemvalue="Go Build.go build github.com/BGrewell/go-iperf/tests/server" />
|
||||
<item itemvalue="Go Build.go build github.com/BGrewell/go-iperf/cmd" />
|
||||
|
||||
244
bindata.go
244
bindata.go
File diff suppressed because one or more lines are too long
1
go.mod
1
go.mod
@@ -9,6 +9,7 @@ require (
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/google/uuid v1.1.2
|
||||
github.com/hpcloud/tail v1.0.0 // indirect
|
||||
github.com/jteeuwen/go-bindata v3.0.7+incompatible // indirect
|
||||
google.golang.org/grpc v1.36.1
|
||||
google.golang.org/protobuf v1.26.0
|
||||
gopkg.in/fsnotify.v1 v1.4.7 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -39,6 +39,8 @@ github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/jteeuwen/go-bindata v3.0.7+incompatible h1:91Uy4d9SYVr1kyTJ15wJsog+esAZZl7JmEfTkwmhJts=
|
||||
github.com/jteeuwen/go-bindata v3.0.7+incompatible/go.mod h1:JVvhzYOiGBnFSYRyV00iY8q7/0PThjIYav1p9h5dmKs=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
||||
19
iperf.go
19
iperf.go
@@ -22,6 +22,11 @@ func init() {
|
||||
if err != nil {
|
||||
log.Fatalf("error initializing iperf: %v", err)
|
||||
}
|
||||
} else if runtime.GOOS == "darwin" {
|
||||
err := extractMacEmbeddedBinaries()
|
||||
if err != nil {
|
||||
log.Fatalf("error initializing iperf: %v\n", err)
|
||||
}
|
||||
} else {
|
||||
err := extractLinuxEmbeddedBinaries()
|
||||
if err != nil {
|
||||
@@ -34,6 +39,13 @@ func Cleanup() {
|
||||
os.RemoveAll(binaryDir)
|
||||
}
|
||||
|
||||
func ExtractBinaries() (err error) {
|
||||
files := []string{"cygwin1.dll", "iperf3.exe", "iperf3", "iperf3.app"}
|
||||
err = extractEmbeddedBinaries(files)
|
||||
fmt.Printf("files extracted to %s\n", binaryDir)
|
||||
return err
|
||||
}
|
||||
|
||||
func extractWindowsEmbeddedBinaries() (err error) {
|
||||
files := []string{"cygwin1.dll", "iperf3.exe"}
|
||||
err = extractEmbeddedBinaries(files)
|
||||
@@ -48,6 +60,13 @@ func extractLinuxEmbeddedBinaries() (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func extractMacEmbeddedBinaries() (err error) {
|
||||
files := []string{"iperf3.app"}
|
||||
err = extractEmbeddedBinaries(files)
|
||||
binaryLocation = path.Join(binaryDir, "iperf3.app")
|
||||
return err
|
||||
}
|
||||
|
||||
func extractEmbeddedBinaries(files []string) (err error) {
|
||||
binaryDir, err = ioutil.TempDir("", "goiperf")
|
||||
if err != nil {
|
||||
|
||||
7
tests/extract/main.go
Normal file
7
tests/extract/main.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
import "github.com/BGrewell/go-iperf"
|
||||
|
||||
func main() {
|
||||
iperf.ExtractBinaries()
|
||||
}
|
||||
Reference in New Issue
Block a user