You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And this is the plugin, that can be compiled using go build -buildmode=plugin pluginReader.go
package main
import (
"C""fmt""bufio""os""io"
)
funcF() {
fmt.Println("Openning file")
f, err:=os.Open("testFile")
iferr!=nil {
fmt.Print(err)
return
}
fmt.Println("Creaating reader with bufio")
r4:=bufio.NewReader(f)
fmt.Printf("Created! Lets copy... %d bytes\n", r4.Buffered())
// This works!!!f2, _:=os.Create("copyOfTestFileA")
_, err=io.Copy(f2, r4)
iferr!=nil {
fmt.Println(err)
}
// This does not work...f2, _=os.Create("copyOfTestFileB")
w:=bufio.NewWriter(f2)
_, err=io.Copy(w, r4)
iferr!=nil {
fmt.Println(err)
}
}
When the execution finished, you will see it creates a copy of the "testFile" (named "copyOfTestFileA"), that has the same content as the first one, and another ("copyOfTestFileB") that is empty. This is the problem I'm getting. What causes that second file to be empty?
The text was updated successfully, but these errors were encountered:
When executing a plugin importing the "C" library, I'm finding some bugs that doesn't let me read and write files with some libraries.
I'm running the application on a Debian amd64 and the go version is go1.8rc1. I've prepared an example that shows how the error appears:
This is the main file that loads the plugin and executes the F function:
And this is the plugin, that can be compiled using
go build -buildmode=plugin pluginReader.go
When the execution finished, you will see it creates a copy of the "testFile" (named "copyOfTestFileA"), that has the same content as the first one, and another ("copyOfTestFileB") that is empty. This is the problem I'm getting. What causes that second file to be empty?
The text was updated successfully, but these errors were encountered: