Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cmd/gen-go-sample/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ import (
"os"
"sort"
"strings"
"time"

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/googleapis/gapic-generator-go/internal/errors"
"github.com/googleapis/gapic-generator-go/internal/license"
"github.com/googleapis/gapic-generator-go/internal/pbinfo"
"github.com/googleapis/gapic-generator-go/internal/printer"
yaml "gopkg.in/yaml.v2"
Expand Down Expand Up @@ -144,8 +146,8 @@ func (g *generator) commit(gofmt bool) error {

firstNonStd := sort.Search(len(imports), func(i int) bool { return strings.IndexByte(imports[i].Path, '.') >= 0 })

// TODO(pongad): add license
var file bytes.Buffer
fmt.Fprintf(&file, license.Apache, time.Now().Year())
file.WriteString("package main\n")
file.WriteString("import(\n")
for i, imp := range imports {
Expand Down
3 changes: 2 additions & 1 deletion gengapic/doc_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/protoc-gen-go/descriptor"
"github.com/googleapis/gapic-generator-go/internal/license"
"google.golang.org/genproto/googleapis/api/annotations"
)

Expand All @@ -29,7 +30,7 @@ import (
func (g *generator) genDocFile(pkgPath, pkgName string, year int, scopes []string) {
p := g.printf

p(apacheLicense, year)
p(license.Apache, year)
p("")

p("// Package %s is an auto-generated package for the", pkgName)
Expand Down
3 changes: 2 additions & 1 deletion gengapic/gengapic.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/golang/protobuf/protoc-gen-go/descriptor"
plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"github.com/googleapis/gapic-generator-go/internal/errors"
"github.com/googleapis/gapic-generator-go/internal/license"
"github.com/googleapis/gapic-generator-go/internal/pbinfo"
"github.com/googleapis/gapic-generator-go/internal/printer"
"google.golang.org/genproto/googleapis/api/annotations"
Expand Down Expand Up @@ -178,7 +179,7 @@ func (g *generator) printf(s string, a ...interface{}) {

func (g *generator) commit(fileName, pkgName string) {
var header strings.Builder
fmt.Fprintf(&header, apacheLicense, time.Now().Year())
fmt.Fprintf(&header, license.Apache, time.Now().Year())
fmt.Fprintf(&header, "package %s\n\n", pkgName)

var imps []pbinfo.ImportSpec
Expand Down
4 changes: 2 additions & 2 deletions gengapic/license.go → internal/license/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package gengapic
package license

const apacheLicense = `// Copyright %d Google LLC
const Apache = `// Copyright %d Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down