Skip to content

adityadani/go-replace-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

go-replace-tag

Replace tags in golang structs

Install

$ go get github.com/adityadani/go-replace-tag

Usage

$ go-replace-tag -input <path-to-pb.go>

Add the following comments to the struct fields which need a tag to be replaced // @replace-tag <tagkey>:"<new tagvalue>"

Example:

api.proto
syntax = "proto3";

// Example for replace tags
message Example {
  // Field1
  string Field1 = 0;
  // Field2
  // @replace-tag json:"-"
  string Field2 = 1;
}

Generate the api.pb.go file

$ protoc api.proto

Replace the tags

$ go-replace-tag -input api.pb.go

Output file:

api.pb.go

type Example struct {
     // Field1
     Field1 string `protobuf:"bytes,15,opt,name=field1" json:"field1,omitempty"`
     // Field2
     // @replace-tag json:"-"
     Field2 string `protobuf:"bytes,15,opt,name=field2" json:"-"`
}

About

Replace tags in golang structs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages