go-protoc-gen-swift

module
v1.28.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2024 License: MIT

README

go-protoc-gen-swift

go-protoc-gen-swift is a distribution of the protoc-gen-swift. It does not actually reimplement any functionality of swift-protobuf in Go, instead compiling it to WebAssembly, and executing with the pure Go Wasm runtime wazero. This means that go install or go run can be used to execute it, with no need to rely on external package managers such as Homebrew, on any platform that Go supports.

Installation

Precompiled binaries are available in the releases. Alternatively, install the plugin using go install.

$ go install github.com/wasilibs/go-protoc-gen-swift/cmd/protoc-gen-swift@latest

As long as $GOPATH/bin, e.g. ~/go/bin is on the PATH, you can use it with protoc as normal.

$ protoc --swift_out=out/swift -Iprotos protos/helloworld.proto

For buf users, to avoid installation entirely, it can be convenient to use go run in buf.gen.yaml.

version: v1
plugins:
  - plugin: swift
    out: out/swift
    path:
      - go
      - run
      - github.com/wasilibs/go-protoc-gen-swift/cmd/protoc-gen-swift@latest

This makes it possible to have full protobuf/gRPC generation with no installation of tools, besides Go itself, on any platform that Go supports. The above examples use @latest, but it is recommended to specify a version, in which case all of the developers on your codebase will use the same version of the tool with no special steps.

See a full example in go-protoc-gen-builtins. To generate protos, enter the directory and run go run github.com/bufbuild/buf/cmd/buf@v1.30.0 generate. As long as your machine has Go installed, you will be able to generate protos. The first time using go run for a command, Go automatically builds it making it slower, but subsequent invocations should be quite fast.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL