Skip to content

Commit

Permalink
build: load package in LoadAllSyntax mode (mmcloughlin#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcloughlin authored Feb 20, 2019
1 parent 9eb409b commit 3cfe40e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewContext() *Context {
// Package sets the package the generated file will belong to. Required to be able to reference types in the package.
func (c *Context) Package(path string) {
cfg := &packages.Config{
Mode: packages.LoadTypes,
Mode: packages.LoadAllSyntax,
}
pkgs, err := packages.Load(cfg, path)
if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions tests/fixedbugs/issue62/asm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// +build ignore

package main

import (
. "github.com/mmcloughlin/avo/build"
)

func main() {
Package("github.com/mmcloughlin/avo/tests/fixedbugs/issue62")
Implement("private")
RET()
Generate()
}
5 changes: 5 additions & 0 deletions tests/fixedbugs/issue62/issue62.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Code generated by command: go run asm.go -out issue62.s. DO NOT EDIT.

// func private()
TEXT ·private(SB), $0
RET
11 changes: 11 additions & 0 deletions tests/fixedbugs/issue62/issue62_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package issue62

import (
"testing"
)

//go:generate go run asm.go -out issue62.s

func TestPrivate(t *testing.T) {
private()
}
5 changes: 5 additions & 0 deletions tests/fixedbugs/issue62/stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Package issue62 tests for using Implement() with an unexported function.
package issue62

// private serves as an example unexported function to implement.
func private()

0 comments on commit 3cfe40e

Please sign in to comment.