xinhao zhang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Go ## 安装 [Download and install](https://go.dev/doc/install) [How To Install Go on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-install-go-on-ubuntu-20-04#conclusion) ```shell= curl -OL https://golang.org/dl/go1.16.7.linux-amd64.tar.gz sudo tar -C /usr/local -xvf go1.16.7.linux-amd64.tar.gz # 环境变量 export GOROOT=/usr/local/go export GOPATH=/opt/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOROOT/bin export PATH=$PATH:$GOPATH/bin ``` ## 开发环境 [为 Go 开发配置Visual Studio Code](https://learn.microsoft.com/zh-cn/azure/developer/go/configure-visual-studio-code) ```shell= # go proxy go env -w GOPROXY=https://goproxy.io,direct # Set environment variable allow bypassing the proxy for selected modules go env -w GOPRIVATE=*.corp.example.com go env -w GO111MODULE=on # go path go env -w GOPATH=/Users/zhangxinhao/code/test/demo/go go env -w GOPATH=/Users/zhangxinhao/go # go bin go env -w GOBIN=/home/zxh/code/go/demo/go/bin ``` ### GoLand ```shell= # 依赖外网三方库的,可设置Proxy,配置环境变量 GO111MODULE=on;GOBIN=D:\Program Files\Go\bin;GOPRIVATE=szv-open.codehub.huawei.com;GOPROXY=http://mirrors.tools.huawei.com/goproxy,direct;GOSUMDB=off ``` ### VSCode ```shell= # 如果您使用的 Go 版本是 1.13 及以上 (推荐) # go proxy go env -w GO111MODULE=on go env -w GOPROXY=https://mirrors.tools.huawei.com/goproxy/ go env -w GONOSUMDB=* go env -w GOSUMDB=off go env -w GOBIN=D:\code\go\path\bin go env -w GOBIN=/opt/go/bin go env -w GOPROXY=http://mirrors.tools.huawei.com/goproxy,direct go env -w GOPROXY=https://repo.huaweicloud.com/repository/goproxy/,direct go env -w GOPRIVATE=*.huawei.com go env -w CGO_ENABLED=1 # 设置不走 proxy 的私有仓库,多个用逗号相隔(可选) go env -w GOPRIVATE=*.corp.example.com # 设置不走 proxy 的私有组织(可选) go env -w GOPRIVATE=example.com/org_name ``` ## 下载私有仓库 ```shell= # 以coastguard为例 # 仓库地址 https://open.codehub.huawei.com/innersource/it-edge-native/edge-native-core/coastguard/files?ref=master # ssh下载地址 ssh://git@szv-open.codehub.huawei.com:2222/innersource/it-edge-native/edge-native-core/coastguard.git # http下载地址 https://szv-open.codehub.huawei.com/innersource/it-edge-native/edge-native-core/coastguard.git@v1.0.6 # 设置http转成ssh下载 git config --global --add url."ssh://git@szv-open.codehub.huawei.com:2222/".insteadOf "https://szv-open.codehub.huawei.com/" git config --global --add url."ssh://git@lfg-y.codehub.huawei.com:2222/".insteadOf "https://codehub-y.huawei.com/" git config --global --add url."ssh://git@codehub-dg-y.huawei.com:2222/".insteadOf "https://codehub-dg-y.huawei.com/" # 下载代码 go get szv-open.codehub.huawei.com/innersource/it-edge-native/edge-native-core/coastguard.git@v1.0.6 # 如果没有权限,可以使用 用户名+token的方式 git config --global --add url."https://{username}:{token}@szv-open.codehub.huawei.com".insteadOf "https://szv-open.codehub.huawei.com" # 因为coastguard库的module命名是huawei.com/kmc和代码库路径不一致,不能直接go get, 需要go mod replace的方式下载 go mod edit -replace huawei.com/kmc=szv-open.codehub.huawei.com/innersource/it-edge-native/edge-native-core/coastguard.git@v1.0.6 ``` ```shell= require huawei.com/kmc v1.0.6 replace huawei.com/kmc => szv-open.codehub.huawei.com/innersource/it-edge-native/edge-native-core/coastguard.git v1.0.6 # 重新下载 go get huawei.com/kmc@v1.0.6 # git配置 # 避免证书校验 git config --global http.sslVerify false # 保存凭证 git config --global credential.helper store ``` # 学习项目 ## 版本 | 主要版本 | 发布日期 | | -------- | ---------- | | 1.0 | 2012-03-28 | | 1.1 | 2013-05-13 | | 1.2 | 2013-12-01 | | 1.3 | 2014-06-18 | | 1.4 | 2014-12-10 | | 1.5 | 2015-08-19 | | 1.6 | 2016-02-17 | | 1.7 | 2016-08-15 | | 1.8 | 2017-02-16 | | 1.9 | 2017-08-24 | | 1.10 | 2018-02-16 | | 1.11 | 2018-08-24 | | 1.12 | 2019-02-25 | | 1.13 | 2019-09-03 | | 1.14 | 2020-02-25 | | 1.15 | 2020-08-11 | | 1.16 | 2021-02-16 | | 1.17 | 2021-08-16 | | 1.18 | 2022-03-15 | | 1.19 | 2022-08-02 | | 1.20 | 2023-02-01 | ## 项目 ### gin-vue-admin [flipped-aurora/gin-vue-admin](https://github.com/flipped-aurora/gin-vue-admin) [项目介绍](https://www.gin-vue-admin.com/guide/introduce/project.html) ```shell= git clone https://github.com/flipped-aurora/gin-vue-admin.git # 生成swagger文档 cd server swag init ``` ### go-admin [go-admin-team/go-admin](https://github.com/go-admin-team/go-admin) [介绍](https://www.go-admin.pro/guide) ## 文章 [一文读懂 Golang init 函数执行顺序](https://cloud.tencent.com/developer/beta/article/2138066) [Go (Golang) GOOS and GOARCH](https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63) Golang 支持交叉编译,在一个平台上生成另一个平台的可执行程序。 GOOS : 目标平台的操作系统 (darwin、freebsd、linux、windows) GOARCH: 目标平台的体系架构 (386、amd64、arm) 交叉编译不支持CGO 所以要禁用它 ## 开源库 ### Viper [spf13/viper](https://github.com/spf13/viper) ### go-logging [op/go-logging](https://github.com/op/go-logging) ### GORM [go-gorm/gorm](https://github.com/go-gorm/gorm)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully