@@ -77,15 +77,21 @@ func archDir() string {
77
77
return ""
78
78
}
79
79
80
+ // includesGodoc reports whether we should include the godoc binary in this release.
81
+ // We only include it in go1.12.x and earlier releases; see issue 30029.
82
+ func includesGodoc () bool {
83
+ _ , version , _ := environ ()
84
+ verMajor , verMinor , _ := splitVersion (version )
85
+ return verMajor == 1 && verMinor < 13
86
+ }
87
+
80
88
// godoc copies the godoc binary into place for Go 1.12 and earlier.
81
89
//
82
90
// TODO: remove this function once Go 1.14 is released (when Go 1.12
83
91
// is no longer supported).
84
92
func godoc () error {
85
- _ , version , _ := environ ()
86
- verMajor , verMinor , _ := splitVersion (version )
87
- if verMajor > 1 || verMinor >= 13 {
88
- return nil // Only include the godoc binary in go1.12.x and earlier releases; Issue 30029
93
+ if ! includesGodoc () {
94
+ return nil
89
95
}
90
96
91
97
// Pre Go 1.7, the godoc binary is placed here by cmd/go.
@@ -247,6 +253,9 @@ func windowsMSI() error {
247
253
// Write out windows data that is used by the packaging process.
248
254
win := filepath .Join (cwd , "windows" )
249
255
defer os .RemoveAll (win )
256
+ if ! includesGodoc () {
257
+ removeGodocShortcut ()
258
+ }
250
259
if err := writeDataFiles (windowsData , win ); err != nil {
251
260
return err
252
261
}
@@ -575,6 +584,13 @@ function installCheck() {
575
584
"Resources/bg.png" : storageBase + "darwin/bg.png" ,
576
585
}
577
586
587
+ // removeGodocShortcut removes the GODOC_SHORTCUT part out of the
588
+ // installer.wxs file contents.
589
+ func removeGodocShortcut () {
590
+ rx := regexp .MustCompile (`(?s)<!--GODOC_SHORTCUT-->.*<!--END_GODOC_SHORTCUT-->` )
591
+ windowsData ["installer.wxs" ] = rx .ReplaceAllString (windowsData ["installer.wxs" ], "" )
592
+ }
593
+
578
594
var windowsData = map [string ]string {
579
595
580
596
"installer.wxs" : `<?xml version="1.0" encoding="UTF-8"?>
@@ -658,14 +674,15 @@ var windowsData = map[string]string{
658
674
<!-- Programs Menu Shortcuts -->
659
675
<DirectoryRef Id="GoProgramShortcutsDir">
660
676
<Component Id="Component_GoProgramShortCuts" Guid="{f5fbfb5e-6c5c-423b-9298-21b0e3c98f4b}">
677
+ <!--GODOC_SHORTCUT-->
661
678
<Shortcut
662
679
Id="GoDocServerStartMenuShortcut"
663
680
Name="GoDocServer"
664
681
Description="Starts the Go documentation server (http://localhost:6060)"
665
682
Show="minimized"
666
683
Arguments='/c start "Godoc Server http://localhost:6060" "[INSTALLDIR]bin\godoc.exe" -http=localhost:6060 -goroot="[INSTALLDIR]." && start http://localhost:6060'
667
684
Icon="gopher.ico"
668
- Target="[%ComSpec]" />
685
+ Target="[%ComSpec]" /><!--END_GODOC_SHORTCUT-->
669
686
<Shortcut
670
687
Id="UninstallShortcut"
671
688
Name="Uninstall Go"
@@ -878,5 +895,13 @@ func runSelfTests() {
878
895
}
879
896
}
880
897
898
+ if ! strings .Contains (windowsData ["installer.wxs" ], "GODOC_SHORTCUT" ) {
899
+ log .Fatal ("expected GODOC_SHORTCUT to be present" )
900
+ }
901
+ removeGodocShortcut ()
902
+ if strings .Contains (windowsData ["installer.wxs" ], "GODOC_SHORTCUT" ) {
903
+ log .Fatal ("expected GODOC_SHORTCUT to be gone" )
904
+ }
905
+
881
906
fmt .Println ("ok" )
882
907
}
0 commit comments