Skip to content

Commit c1a7e80

Browse files
ipriverSteve Traut
authored and
Steve Traut
committed
doc/install: fix Linux tab installation command
There is a command on doc/install page https://golang.org/doc/install that uses an outdated filename that is being shown as an example of how to install go for Linux: tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz Currently, there is a button that allows downloading .tar file that include go1.15 and its name is different from the command, so that if you follow installation steps you'll get an error that .tar file wasn't found. Changes purposed: Added a function that uses a filename from the "Download" button that can be used to update Linux installation command. This function could be used in the future for other OSes if there will be a need for adding informational data that may change in the future. So there's no need to update such data in the markup files. If there's something wrong during running JS code (or JS is disabled in the browser) and the filename couldn't be parsed - the old filename is used as an example like before. Fixes golang/go#41232 Change-Id: Ie389ce73de5393f151ad739b3e97873e1a9be179 GitHub-Last-Rev: 0a93f69 GitHub-Pull-Request: #15 Reviewed-on: https://go-review.googlesource.com/c/website/+/253118 Run-TryBot: Steve Traut <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Steve Traut <[email protected]>
1 parent 97c2bf7 commit c1a7e80

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

content/static/doc/download.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ class DownloadsController {
8484
}
8585
}
8686

87+
// Updates install tab with dynamic data.
88+
setInstallTabData(osName) {
89+
const fnId = `#${osName}-filename`;
90+
const el = document.querySelector(fnId);
91+
if (!el) {
92+
return;
93+
}
94+
switch(osName) {
95+
case 'linux':
96+
// Update filename for linux installation step
97+
if (this.linuxFileName) {
98+
el.textContent = this.linuxFileName;
99+
}
100+
break;
101+
}
102+
}
103+
87104
// Detect the users OS for installation default.
88105
detectOS() {
89106
if (navigator.appVersion.indexOf('Linux') !== -1) {
@@ -117,6 +134,7 @@ class DownloadsController {
117134
const el = (e.target);
118135
this.activateTab(Array.prototype.indexOf.call(this.tabs, el));
119136
this.setDownloadForOS(el.id);
137+
this.setInstallTabData(el.id);
120138
}
121139

122140
}

content/static/doc/install.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ <h2 id="install">2. Go install.</h2>
9191
For example, run the following as root or through <code>sudo</code>:
9292
</p>
9393
<pre>
94-
tar -C /usr/local -xzf go1.14.3.linux-amd64.tar.gz
94+
tar -C /usr/local -xzf <span id="linux-filename">go1.14.3.linux-amd64.tar.gz</span>
9595
</pre
9696
>
9797
</li>
@@ -201,4 +201,4 @@ <h2 id="code">3. Go code.</h2>
201201
some simple Go code. It takes about 10 minutes to complete.
202202
</p>
203203

204-
<script async src="/doc/download.js"></script>
204+
<script async src="/doc/download.js"></script>

0 commit comments

Comments
 (0)