This commit is contained in:
yoanm 2025-06-20 15:37:04 -04:00 committed by GitHub
commit 5f44f202f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 0 deletions

View File

@ -232,6 +232,9 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File {
// We can't resolve dot imports (yet).
return nil
}
} else {
// Trim 'go-' prefix from package name (like done at runtime) to ensure match
n = strings.TrimPrefix(n, "go-")
}
if unresolved[n] {
// Copy the spec and its path to avoid modifying the original.

View File

@ -0,0 +1,17 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package foo_test
import (
"fmt"
"github.com/xxx/go-foo"
)
func ExampleMyMethod() {
fmt.Println(foo.MyMethod())
// Output:
// expected output
}

View File

@ -0,0 +1,14 @@
-- MyMethod.Play --
package main
import (
"fmt"
"github.com/xxx/go-foo"
)
func main() {
fmt.Println(foo.MyMethod())
}
-- MyMethod.Output --
expected output