go

Calling “sed” from exec.Command

倾然丶 夕夏残阳落幕 提交于 2021-01-28 17:45:00
问题 I'm currently having trouble trying to run this code which is supposed to call the unix command sed to find and replace the string hello with goodbye in the file ./myfile.txt This works fine if you run it from the command line, but if I try the same thing from my Go code.... command := exec.Command("sed", "-e \"s/hello/goodbye/g\" ./myfile.txt") result,err := command.CombinedOutput() fmt.Println(string(result)) Bit I just keep on getting this output sed: -e expression #1, char 2: unknown

Golearn models are implicit about independent variables (predictors) and targets (predicted)

回眸只為那壹抹淺笑 提交于 2021-01-28 17:10:37
问题 I am learning ML in Go. I was exploring Golearn Package in Go, for ML support. I am very confused with the way the model.fit and model.predict functions are implemented. For example in this example implementation of Knn Classifier from Golearn repo: rawData, err := base.ParseCSVToInstances("../datasets/iris_headers.csv", true) cls := knn.NewKnnClassifier("euclidean", "linear", 2) trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50) cls.Fit(trainData) predictions, err := cls

Golearn models are implicit about independent variables (predictors) and targets (predicted)

对着背影说爱祢 提交于 2021-01-28 17:08:21
问题 I am learning ML in Go. I was exploring Golearn Package in Go, for ML support. I am very confused with the way the model.fit and model.predict functions are implemented. For example in this example implementation of Knn Classifier from Golearn repo: rawData, err := base.ParseCSVToInstances("../datasets/iris_headers.csv", true) cls := knn.NewKnnClassifier("euclidean", "linear", 2) trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50) cls.Fit(trainData) predictions, err := cls

Golearn models are implicit about independent variables (predictors) and targets (predicted)

最后都变了- 提交于 2021-01-28 17:06:10
问题 I am learning ML in Go. I was exploring Golearn Package in Go, for ML support. I am very confused with the way the model.fit and model.predict functions are implemented. For example in this example implementation of Knn Classifier from Golearn repo: rawData, err := base.ParseCSVToInstances("../datasets/iris_headers.csv", true) cls := knn.NewKnnClassifier("euclidean", "linear", 2) trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50) cls.Fit(trainData) predictions, err := cls

Golearn models are implicit about independent variables (predictors) and targets (predicted)

会有一股神秘感。 提交于 2021-01-28 17:05:59
问题 I am learning ML in Go. I was exploring Golearn Package in Go, for ML support. I am very confused with the way the model.fit and model.predict functions are implemented. For example in this example implementation of Knn Classifier from Golearn repo: rawData, err := base.ParseCSVToInstances("../datasets/iris_headers.csv", true) cls := knn.NewKnnClassifier("euclidean", "linear", 2) trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50) cls.Fit(trainData) predictions, err := cls

Struct is empty after Json unmarshal when accessed by another package

佐手、 提交于 2021-01-28 14:20:44
问题 I'm am using a struct Contact that has a Load() method. The idea is that Load() populates Contact 's fields with data. The data is unmarshalled from json returned by a server. Once loaded, I want to be able to access the data on Contact . I know that the json is unmarshalling correctly because I can print the data to the console within Load() , immediately after it has been unmarshalled. However, this data is not present on Contact once it has been loaded. So when I create a new Contact and

Go: undefined function in same package [duplicate]

自作多情 提交于 2021-01-28 12:59:14
问题 This question already has answers here : go build works fine but go run fails (2 answers) Closed 3 years ago . I've started Go and am trying to follow this tutorial. Everything builds correct but as I try to run it, I get the error that makeRouter() could not be found. I had a look at some other questions, like this one, and checked the docs, but I couldn't find out whats wrong with my setup. My folder structure: .../wattagebazooka/ |- wattagebazooka.go |- router.go |- handler.go Code

Go: undefined function in same package [duplicate]

ε祈祈猫儿з 提交于 2021-01-28 12:56:43
问题 This question already has answers here : go build works fine but go run fails (2 answers) Closed 3 years ago . I've started Go and am trying to follow this tutorial. Everything builds correct but as I try to run it, I get the error that makeRouter() could not be found. I had a look at some other questions, like this one, and checked the docs, but I couldn't find out whats wrong with my setup. My folder structure: .../wattagebazooka/ |- wattagebazooka.go |- router.go |- handler.go Code

Go func closure in loop

◇◆丶佛笑我妖孽 提交于 2021-01-28 12:40:54
问题 When executing the following code I get what I expect when the first loop is done (sequence from 0 to 9). But when the second loop finishes, the result is not what I expected (I expected the same result as in the first loop, but it prints only '10's): package main import ( "fmt" "sync" ) func main() { var wg sync.WaitGroup for i := 0; i < 10; i++ { wg.Add(1) go func(j int) { defer wg.Done() fmt.Println(j) }(i) } wg.Wait() fmt.Println("done first") for i := 0; i < 10; i++ { wg.Add(1) go func()

Golang - pass struct as argument to function

血红的双手。 提交于 2021-01-28 12:24:50
问题 I have to parse some nested JSON, which translates into a Go type, like this: type Config struct { Mail struct { From string To string Password string } Summary struct { Send bool Interval int } } Now I want to call a function for each key (Mail, Summary), I tried it like this: utils.StartNewMailer(config.Mail) The problem is, how do I construct the called function, I tried to mirror the Mail struct (and called it mailConfig ), since I can't pass an arbitrary struct as an argument. func