internal/wire: factor out common code in solve (#98)

- Fixed a bug when a interface is bind to a value wire would fail to record it is used.
- Also rename ProvidedType.ConcreteType to Type since it doesn't necessarily returns a concrete type.

Fixes #72
This commit is contained in:
shantuo
2018-12-14 12:56:01 -08:00
committed by Ross Light
parent f9328a1d90
commit 4243b011bd
7 changed files with 103 additions and 41 deletions

View File

@@ -0,0 +1,20 @@
// Copyright 2018 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
func main() {
w := inject()
w.Write([]byte("Hello, World!"))
}

View File

@@ -0,0 +1,32 @@
// Copyright 2018 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 (
"io"
"os"
"github.com/google/wire"
)
func inject() io.Writer {
wire.Build(
wire.Value(os.Stdout),
wire.Bind(new(io.Writer), new(os.File)),
)
return nil
}

View File

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

View File

@@ -0,0 +1 @@
Hello, World!

View File

@@ -0,0 +1,22 @@
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package main
import (
"io"
"os"
)
// Injectors from wire.go:
func inject() io.Writer {
file := _wireFileValue
return file
}
var (
_wireFileValue = os.Stdout
)