diff --git a/internal/godoc/dochtml/dochtml_test.go b/internal/godoc/dochtml/dochtml_test.go index 9b443b418..271142caa 100644 --- a/internal/godoc/dochtml/dochtml_test.go +++ b/internal/godoc/dochtml/dochtml_test.go @@ -178,6 +178,32 @@ func main() { 0 1 + +
+ + + + +
`, + }, + { + name: "Example without output", + htmlID: "example-package-NoOutput", + want: `
+Example (NoOutput) +
+ +
package main
+
+import (
+	"fmt"
+)
+
+func main() {
+	fmt.Println("hello")
+}
+
+
diff --git a/internal/godoc/dochtml/testdata/example_test.go b/internal/godoc/dochtml/testdata/example_test.go index 83b615e1c..c4249b1a8 100644 --- a/internal/godoc/dochtml/testdata/example_test.go +++ b/internal/godoc/dochtml/testdata/example_test.go @@ -46,3 +46,7 @@ func Example_stringsCompare() { // 0 // 1 } + +func Example_noOutput() { + fmt.Println("hello") +} diff --git a/static/doc/example.tmpl b/static/doc/example.tmpl index 8044c0c3d..b5d7e2349 100644 --- a/static/doc/example.tmpl +++ b/static/doc/example.tmpl @@ -15,7 +15,7 @@

Open in Go playground »

{{"\n" -}} {{- end -}} {{render_code .Example}}{{"\n" -}} -
Output:{{"\n\n"}}{{- .Output -}}
{{"\n" -}} + {{- if .Output -}}
Output:{{"\n\n"}}{{- .Output -}}
{{"\n" -}}{{- end -}}
{{"\n" -}} {{- if .Play -}}