INNER CODE UNIT · Go
sendFile
kluctl/kluctl · internal/ipfs-exchange-info/main.go:439
func sendFile(ctx context.Context, h host.Host, ipfsId peer.ID, data []byte) error {
s, err := h.NewStream(ctx, ipfsId, "/x/kluctl-preview-info")
if err != nil {
return fmt.Errorf("failed to connect to %s: %w", ipfsId.String(), err)
}
defer s.Close()
enc := gob.NewEncoder(s)
dec := gob.NewDecoder(s)
err = enc.Encode(data)
if err != nil {
return fmt.Errorf("failed to send msg: %w", err)
}
var ok string
err = dec.Decode(&ok)
if err != nil {