如何在Chrome OS上安装Golang

发布于 2025-02-10 12:50:46 字数 367 浏览 1 评论 0 原文

我尝试了 https://go.dev/doc/install ,我继续获得的方法。 bash:go:找不到命令”。 我尝试了“ nofollow noreferrer”>知道什么当我到达“使用ARM64设备上的SFTP或SCP来获取tar.gz文件”阶段时,请运行。有帮助吗???

I tried the method from https://go.dev/doc/install and I keep getting "-bash: go: command not found".
I tried https://gist.github.com/conoro/4fca191fad018b6e47922a21fab499ca but I dont know what command to run when I get to the "Use sftp or scp on the ARM64 device to get the tar.gz file" stage. Any help???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只有影子陪我不离不弃 2025-02-17 12:50:46

您无需在开发人员模式下从源中进行编译,只需使用 chromebrew - 。

如果您的Chromebook相对较新,则可以启用Chromeos中内置的Linux VM在没有开发人员模式的情况下安装。请按照以下Google支持文章的步骤启用此功能 - https://support.google。 com/chromebook/answer/9145439 。这已在版本71.0.3578.127上的三星Chromebook Plus上进行了测试。如果此功能不适合您,则需要启用开发人员模式。

本教程将向您展示如何在Chrome OS上安装,构建和运行。
请注意,仅在64GB LTE像素上进行了测试,但是它应该在其他Chromebook上使用。请注意,启用开发人员模式可降低Chrome OS提供的安全保证。

安装GO

首先从 shell 然后点击Enter。然后使用以下命令提取它(替换< go linux软件包> 使用您下载的文件的名称):

sudo tar xpvf ~/Downloads/< Go Linux package > -C /usr/local

现在应该安装GO,您可以通过键入/usr进行测试/local/go/bin/go 。如果安装正确,则应看到GO帮助提示。 GO现在已安装。

创建一个工作空间

以保持此简单,只需创建一个称为/usr/usr/local/go/work 的文件夹即可。另外,创建一个名为 src 内部的文件夹/usr/usr/local/go/work/code>。

将路径

设置为〜/.bashrc

export GOPATH="/usr/local/go/work"
export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"

这将使您可以在外壳中运行GO程序。

测试是否工作,

首先在/usr/usr/local/go/src 文件夹中创建一个文件夹。之后,在您的文件夹中创建一个名为 hello.go.go 的文件,其中包括以下内容:

package main

import "fmt"

func main() {
    fmt.Println("Hello, Chrome OS!")
}

现在,运行 go install hello 。然后,运行 $ {gopath}/bin/hello (或者只是 hello ,如果您在上面设置了gopath),并且您应该看到 hello,chrome os!


收集: https://github.com/golang.com/golang/go/ Wiki/Chromeos

You don't need to compile from source in Developer mode, you can just use the Chromebrew-provided version.

If your Chromebook is relatively new, you can enable the Linux VM now built into ChromeOS to install Go without developer mode. Follow the steps from the following Google Support article to enable this feature- https://support.google.com/chromebook/answer/9145439. This has been tested on a Samsung Chromebook Plus on version 71.0.3578.127. If this feature is not available for you, you will need to enable Developer Mode.

This tutorial will show you how to install, build, and run Go on Chrome OS.
Please note this has only been tested on a 64GB LTE Pixel, however it should work on other Chromebooks. Note that enabling developer mode reduces the security guarantees offered by Chrome OS.

Install Go

First download the latest version of Go for Linux from the Go Downloads page.
After that, open a shell by hitting (CTRL+ALT+T) and typing in shell then hit enter. Then extract it using the following command (when replacing < Go Linux package > with the name of the file you downloaded):

sudo tar xpvf ~/Downloads/< Go Linux package > -C /usr/local

Go should now be installed you can test this by typing /usr/local/go/bin/go. If it installed correctly, you should see the Go help prompt. Go is now installed.

Create a Workspace

To keep this simple just create a folder called /usr/local/go/work. Also, create a folder called src inside /usr/local/go/work/.

Set PATH

Add the following to ~/.bashrc:

export GOPATH="/usr/local/go/work"
export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"

This will allow you to run your Go programs in your shell.

Test if it worked

First create a folder inside of your /usr/local/go/src folder. After that create a file in your folder called hello.go with the following in it:

package main

import "fmt"

func main() {
    fmt.Println("Hello, Chrome OS!")
}

Now, run go install hello. Then, run ${GOPATH}/bin/hello (or just hello if you setup your GOPATH above) and you should see Hello, Chrome OS!.


Collected from : https://github.com/golang/go/wiki/ChromeOS

守望孤独 2025-02-17 12:50:46

如果您想在Dev模式下下载Chromebook,而无需安装Linux,请按照以下步骤:

  1. Enable Dev模式,以防您尚未。
  2. 下载for Linux的最新版本( https://go.dev/dl/

)在您的终端

type shell

mkdir ~/Coding
tar -xzf ~/Downloads/ADD YOUR VERSION HERE -C ~/Coding/  
echo "sudo mount -i -o remount,exec /home/chronos/user/" >> ~/.bash_profile
echo "sudo mount -i -o remount,exec /tmp/" >> ~/.bash_profile

设置env变量

export GOROOT=~/CS/go *Where you extracted Go*
export GOPATH=~/Downloads/go *Where you wanna keep your Go projects*
PATH=$PATH:$GOROOT/bin:$GOPATH/bin *This adds everything to PATH*

以确保一切正常工作重新启动您的终端并键入 GO版本您应该应该请参阅您安装的版本

If you want to download Go on a Chromebook in Dev Mode, without installing Linux follow these steps:

  1. Enable Dev mode, in case you have not already.
  2. Download the latest version of Go for Linux (https://go.dev/dl/)

IN YOUR TERMINAL

Type Shell

mkdir ~/Coding
tar -xzf ~/Downloads/ADD YOUR VERSION HERE -C ~/Coding/  
echo "sudo mount -i -o remount,exec /home/chronos/user/" >> ~/.bash_profile
echo "sudo mount -i -o remount,exec /tmp/" >> ~/.bash_profile

SET ENV VARIABLES

export GOROOT=~/CS/go *Where you extracted Go*
export GOPATH=~/Downloads/go *Where you wanna keep your Go projects*
PATH=$PATH:$GOROOT/bin:$GOPATH/bin *This adds everything to PATH*

To make sure everything works restart your Terminal and type go version you should see the version you installed

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文