internal/wire: copy doc comment for generated injectors (#254)
Fixes #244
This commit is contained in:
28
internal/wire/testdata/DocComment/foo/foo.go
vendored
Normal file
28
internal/wire/testdata/DocComment/foo/foo.go
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright 2020 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"
|
||||
)
|
||||
|
||||
type (
|
||||
Bar struct{}
|
||||
Foo struct{}
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("Hello, World")
|
||||
}
|
||||
31
internal/wire/testdata/DocComment/foo/wire.go
vendored
Normal file
31
internal/wire/testdata/DocComment/foo/wire.go
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2020 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"
|
||||
)
|
||||
|
||||
/* blockComment returns Foo and has a /*- style doc comment */
|
||||
func blockComment() *Foo {
|
||||
panic(wire.Build(wire.Struct(new(Foo))))
|
||||
}
|
||||
|
||||
// lineComment returns Bar and has a //- style doc comment
|
||||
func lineComment() *Bar {
|
||||
panic(wire.Build(wire.Struct(new(Bar))))
|
||||
}
|
||||
1
internal/wire/testdata/DocComment/pkg
vendored
Normal file
1
internal/wire/testdata/DocComment/pkg
vendored
Normal file
@@ -0,0 +1 @@
|
||||
example.com/foo
|
||||
1
internal/wire/testdata/DocComment/want/program_out.txt
vendored
Normal file
1
internal/wire/testdata/DocComment/want/program_out.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Hello, World
|
||||
20
internal/wire/testdata/DocComment/want/wire_gen.go
vendored
Normal file
20
internal/wire/testdata/DocComment/want/wire_gen.go
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Code generated by Wire. DO NOT EDIT.
|
||||
|
||||
//go:generate wire
|
||||
//+build !wireinject
|
||||
|
||||
package main
|
||||
|
||||
// Injectors from wire.go:
|
||||
|
||||
/* blockComment returns Foo and has a /*- style doc comment */
|
||||
func blockComment() *Foo {
|
||||
foo := &Foo{}
|
||||
return foo
|
||||
}
|
||||
|
||||
// lineComment returns Bar and has a //- style doc comment
|
||||
func lineComment() *Bar {
|
||||
bar := &Bar{}
|
||||
return bar
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package main
|
||||
|
||||
// Injectors from wire.go:
|
||||
|
||||
// initApp returns a real app.
|
||||
func initApp() *app {
|
||||
mainTimer := _wireRealTimeValue
|
||||
mainGreeter := greeter{
|
||||
@@ -22,6 +23,9 @@ var (
|
||||
_wireRealTimeValue = realTime{}
|
||||
)
|
||||
|
||||
// initMockedAppFromArgs returns an app with mocked dependencies provided via
|
||||
// arguments (Approach A). Note that the argument's type is the interface
|
||||
// type (timer), but the concrete mock type should be passed.
|
||||
func initMockedAppFromArgs(mt timer) *app {
|
||||
mainGreeter := greeter{
|
||||
T: mt,
|
||||
@@ -32,6 +36,8 @@ func initMockedAppFromArgs(mt timer) *app {
|
||||
return mainApp
|
||||
}
|
||||
|
||||
// initMockedApp returns an app with its mocked dependencies, created
|
||||
// via providers (Approach B).
|
||||
func initMockedApp() *appWithMocks {
|
||||
mainMockTimer := newMockTimer()
|
||||
mainGreeter := greeter{
|
||||
|
||||
Reference in New Issue
Block a user