mukan-ignite/docs/versioned_docs/version-v29/07-packages/cosmosbuf.md
Mukan Erkin Törük 26b204bd04
Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
feat: fork Ignite CLI v29 as Mukan Ignite — remove cosmos-sdk restrictions
2026-05-11 03:31:37 +03:00

1.3 KiB

sidebar_position title slug
14 Buf Integration (cosmosbuf) /packages/cosmosbuf

Buf Integration (cosmosbuf)

The cosmosbuf package wraps Buf workflows (generate, export, format, migrate, dep update) used by Ignite's protobuf pipelines.

For full API details, see the cosmosbuf Go package documentation.

When to use

  • Trigger Buf code generation from Go services.
  • Keep Buf invocation flags and error handling consistent.
  • Reuse cache-aware generation behavior.

Key APIs

  • New(cacheStorage cache.Storage, goModPath string) (Buf, error)
  • (Buf) Generate(ctx, protoPath, output, template, options...)
  • (Buf) Format(ctx, path)
  • (Buf) Export(ctx, protoDir, output)
  • Version(ctx context.Context) (string, error)

Example

package main

import (
	"context"
	"log"
	"os"
	"path/filepath"

	"github.com/ignite/cli/v29/ignite/pkg/cache"
	"github.com/ignite/cli/v29/ignite/pkg/cosmosbuf"
)

func main() {
	storage, err := cache.NewStorage(filepath.Join(os.TempDir(), "ignite-cache.db"))
	if err != nil {
		log.Fatal(err)
	}

	buf, err := cosmosbuf.New(storage, "github.com/acme/my-chain")
	if err != nil {
		log.Fatal(err)
	}

	if err := buf.Format(context.Background(), "./proto"); err != nil {
		log.Fatal(err)
	}
}