Hi there I just want to create a simple golang applications, which posts a new dent at identi.ca using
curl -u username:password http://example.com/api/statuses/update.xml -d status='Howdy!' -d lat='30.468' -d long='-94.743'
This is my code so far and imho this should work, but actually it isn’t working, does anybody know how to fix this?
EDIT: Nope: I don’t get any error messages :/
package main
import(
"fmt"
"os"
"bufio"
"exec"
)
func main() {
var err os.Error
var username string
print("Username: ")
_, err = fmt.Scanln(&username)
if err != nil {
fmt.Println("Error: ", err)
}
var password string
print("Password: ")
_, err = fmt.Scanln(&password)
if err != nil {
fmt.Println("Error: ", err)
}
var status string
print("Status: ")
in := bufio.NewReader(os.Stdin);
status, err = in.ReadString('\n');
if err != nil {
fmt.Println("Error: ", err)
}
exec.Command("curl -u " + username + ":" + password + "https://identi.ca/api/statuses/update.xml -d status='" + status + "'" + "-d source='API'").Run()
exec.Command()doesn’t take the whole command line as a single argument. You need to call it as:How do you know if you get an error? You don’t check the return value of
Run().You should actually separate the command creation from running it. This way you can set the process’s stdout and stderr to something besides
/dev/null, e.g.