Skip to content

AlexBrochu/golang-package-tuto

Repository files navigation

proto-lib

npm (scoped) npm bundle size

Proto library to test how to publish a lib in npm

Install

npm install @alexbrochu/proto-lib

Usage

let protobuf = require("protobufjs");

async function run() {
  let root = await protobuf.load(
    "node_modules/@alexbrochu/proto-lib/Protobuf lib/lib/constant.proto"
  );

  const Corpus = root.lookupEnum("awesomepackage.Corpus");
  // console.log("Test ENUM", Corpus);

  console.log("Corpus", Corpus.values.CORPUS_UNIVERSAL);
}

run().catch((err) => console.log(err));

How to link a package before sending it to npm repository?

This command will be link you node_modules package locally to your other project. Here I'm using @alexbrochu/proto-lib from my local environment

npm link @package/name

Once tested you can use this command to bump the npm version and publis to npm repository

You have to login to npm before publishing

npm login
npm version [major-minor]
npm publish --access public # this will publish your package so it's available to everyone

Generate proto.pb.go

To generate the proto pb source, you need to have this dependency install see

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc -I. -Ivendors --go_out=vendors  lib/constant.proto

Super useful video

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published