It’s Cybersecurity Awareness Month! Join our interactive training session, or learn about security and AI from 1Password experts.
Forum Discussion
Former Member
3 years ago"error initializing client: connecting to desktop app: read: connection reset"
I am trying to execute the op command from a Golang app like so:
```
package main
import (
"encoding/json"
"log"
"os/exec"
)
func main() {
op := exec.Command("o...
Former Member
3 years agoInterestingly enough, when I call the Python script from the Go app, it works fine. Given the following Python script named op.py
:
```
!/usr/bin/env python
import subprocess
subprocess.run(["op", "item", "get", "DocSend", "--format=json"])
```
and the following Go app in the same directory:
```
package main
import (
"encoding/json"
"fmt"
"log"
"os/exec"
)
func main() {
op := exec.Command("/usr/bin/python3.11", "./op.py")
//op := exec.Command("op", "item", "get", "DocSend", "--format=json")
out, err := op.Output()
if e, ok := err.(*exec.ExitError); ok {
log.Fatal(e, ": ", string(e.Stderr))
}
fmt.Printf("%s", out)
var item map[string]interface{}
if err := json.Unmarshal(out, &item); err != nil {
log.Fatal(err)
}
fmt.Println(item["fields"])
}
```
...it works fine, the output gets printed. I can test that it is being printed by the Go app and not by the Python script because if I remove the fmt.Printf(...)
and below, nothing gets printed.