分享
  1. 首页
  2. 文章

Mac环境 go语言之入门HelloWorld

angel22xu · · 4658 次点击 · · 开始浏览
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

1. 安装mercurial

Mercurial 是一种轻量级分布式版本控制系统,采用 Python 语言实现

可以输入hg命令查询系统是否安装mercurial,可以如下两种命令安装

$sudo pip install mercurial


安装成功之后

$sudo easy-install mercurial


安装之后,输入hg命令,如下内容显示,表示成功安装 mercuria

$ hg

Mercurial Distributed SCM


basic commands:


add add the specified files on the next commit

annotate show changeset information by line for each file

clone make a copy of an existing repository

commit commit the specified files or all outstanding changes

diff diff repository (or selected files)

export dump the header and diffs for one or more changesets

forget forget the specified files on the next commit

init create a new repository in the given directory

log show revision history of entire repository or files

merge merge working directory with another revision

pull pull changes from the specified source

push push changes to the specified destination

remove remove the specified files on the next commit

serve start stand-alone webserver

status show changed files in the working directory

summary summarize working directory state

update update working directory (or switch revisions)


use "hg help" for the full list of commands or "hg -v" for details

如上命令安装失败,可以直接去下载安装

2. 获取go源代码

$hg clone -r release https://go.googlecode.com/hg/ go

warning: go.googlecode.com certificate with fingerprint 3f:8a:ae:12:fc:c2:65:d0:64:42:ee:6f:cc:b3:41:a1:9a:76:6e:8c not verified (check hostfingerprints or web.cacerts config setting)

adding changesets

adding manifests

adding file changes

added 19559 changesets with 68116 changes to 8835 files

updating to branch release-branch.go1.3

4167 files updated, 0 files merged, 0 files removed, 0 files unresolved

会在当前路径创建go目录

3.安装go

进入 go源码(go/src)目录进行安装,执行如下命令

$ ./all.bash

最后会显示出如下内容


ALL TESTS PASSED


---

Installed Go for darwin/amd64 in /Users/angel/iProject/go

Installed commands in /Users/angel/iProject/go/bin

*** You need to add /Users/angel/iProject/go/bin to your PATH.

4.编写HelloWorld

$ cat helloworld.go

package main


import (

"fmt"

)



func main(){

fmt.Println("Hello World")

}

5.运行程序

$ go run helloworld.go

Hello World


参考 链接


有疑问加站长微信联系(非本文作者)

本文来自:CSDN博客

感谢作者:angel22xu

查看原文:Mac环境 go语言之入门HelloWorld

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

关注微信
4658 次点击
1 回复 | 直到 2025年05月15日 08:50:01
暂无回复
添加一条新回复 (您需要 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传

用户登录

没有账号?注册
(追記) (追記ここまで)

今日阅读排行

    加载中
(追記) (追記ここまで)

一周阅读排行

    加载中

关注我

  • 扫码关注领全套学习资料 关注微信公众号
  • 加入 QQ 群:
    • 192706294(已满)
    • 731990104(已满)
    • 798786647(已满)
    • 729884609(已满)
    • 977810755(已满)
    • 815126783(已满)
    • 812540095(已满)
    • 1006366459(已满)
    • 692541889

  • 关注微信公众号
  • 加入微信群:liuxiaoyan-s,备注入群
  • 也欢迎加入知识星球 Go粉丝们(免费)

给该专栏投稿 写篇新文章

每篇文章有总共有 5 次投稿机会

收入到我管理的专栏 新建专栏