cmd/wire: add a --header_file flag to the "gen" and "diff" commands (#175)

This commit is contained in:
Robert van Gent
2019-05-16 09:56:42 -07:00
committed by GitHub
parent d76a979091
commit fe01654174
10 changed files with 133 additions and 11 deletions

View File

@@ -0,0 +1,29 @@
// Copyright 2019 The Wire Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"fmt"
)
func main() {
fmt.Println(injectFoo())
}
type Foo int
func provideFoo() Foo {
return 41
}

View File

@@ -0,0 +1,26 @@
// Copyright 2019 The Wire Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//+build wireinject
package main
import (
"github.com/google/wire"
)
func injectFoo() Foo {
wire.Build(provideFoo)
return Foo(0)
}

2
internal/wire/testdata/Header/header vendored Normal file
View File

@@ -0,0 +1,2 @@
// This is a sample header file.
//

1
internal/wire/testdata/Header/pkg vendored Normal file
View File

@@ -0,0 +1 @@
example.com/foo

View File

@@ -0,0 +1 @@
41

View File

@@ -0,0 +1,15 @@
// This is a sample header file.
//
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package main
// Injectors from wire.go:
func injectFoo() Foo {
foo := provideFoo()
return foo
}