typings icon indicating copy to clipboard operation
typings copied to clipboard

feat: add comment 'Generated: DO NOT EDIT' disclaimer to generated (Go,...?) typed files

Open meowsbits opened this issue 5 years ago • 0 comments
trafficstars

The following command produces a type Go file with head as below

> open-rpc-typings --output-go goout -d https://raw.githubusercontent.com/open-rpc/examples/master/service-descriptions/petstore-expanded-openrpc.json
> head goout/index.go 
type StringDoaGddGA string
type UnorderedSetOfStringDoaGddGADvj0XlFa []StringDoaGddGA
type Integer2AHOqbcQ int64
type ObjectOfStringDoaGddGAStringDoaGddGAUbqj18UU struct {
        Name *StringDoaGddGA `json:"name"`
        Tag  *StringDoaGddGA `json:"tag,omitempty"`
}
type AnyBrndsk4F interface{}
type AllOfAnyBrndsk4FObjectOfStringDoaGddGAStringDoaGddGAUbqj18UUKZp9HQVl map[string]interface{}
type UnorderedSetOfAllOfAnyBrndsk4FObjectOfStringDoaGddGAStringDoaGddGAUbqj18UUKZp9HQVlL0I1EEvd []AllOfAnyBrndsk4FObjectOfStringDoaGddGAStringDoaGddGAUbqj18UUKZp9HQVl

In Go, it is conventional to prepend a "Generated - DO NOT EDIT" disclaimer comment at or near the top of generated files. This is useful for both robots and humans futher down the line. I don't know of any "canonical" phrase or sentence; usually includes the bespoke four words, though caps and ordering and punctuation may vary.

  • https://github.com/fjl/gencodec/blob/e283372f291f5533d8bfd25ac5e767b4df9fef33/main.go#L238
  • https://github.com/go-bindata/go-bindata/blob/b139d7db0394bd41b5c1fbb5612e2314e3f6a29b/convert.go#L53

I don't know if this applies to other languages like Rust and Typescript too... ?

meowsbits avatar Jan 28 '20 14:01 meowsbits