2021-07-27 20:09:06 +00:00
|
|
|
---
|
|
|
|
author: Alvie Rahman
|
|
|
|
date: \today
|
|
|
|
title: Go (golang)
|
2022-03-02 01:43:54 +00:00
|
|
|
tags:
|
|
|
|
- golang
|
|
|
|
- programming
|
|
|
|
uuid: 70d24c2e-25f6-4a46-9756-659d13b5149f
|
2021-07-27 20:09:06 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Getting Up to Speed With Go
|
|
|
|
|
|
|
|
Probably the most useful resoure I found was the [Tour of Go](https://tour.golang.org/).
|
|
|
|
It's easy to understand and teaches you all you need to know.
|
|
|
|
|
2021-08-04 13:23:31 +00:00
|
|
|
# `godoc` [^golang-godoc]
|
|
|
|
|
|
|
|
> Godoc parses Go source code - including comments - and produces documentation as HTML or plain
|
|
|
|
> text.
|
|
|
|
> The end result is documentation tightly coupled with the code it documents.
|
2021-09-01 15:42:01 +00:00
|
|
|
> For example, through godoc's web interface [which is at <http://localhost:6060> by default] you
|
|
|
|
> can navigate from a function's documentation to its implementation with one click.
|
2021-08-04 13:23:31 +00:00
|
|
|
|
|
|
|
## Installing godoc // `command not found: godoc`
|
|
|
|
|
|
|
|
```bash
|
|
|
|
go get golang.org/x/tools/cmd/godoc
|
|
|
|
```
|
|
|
|
|
2021-08-04 13:38:23 +00:00
|
|
|
# `go.mod`
|
|
|
|
|
|
|
|
## `replace` [^go-mod-edit]
|
|
|
|
|
|
|
|
```
|
|
|
|
go mod edit -replace old.repo/location=../new/location
|
|
|
|
```
|
|
|
|
|
2021-08-04 13:41:59 +00:00
|
|
|
or
|
|
|
|
|
|
|
|
```
|
|
|
|
echo "old.repo/location => ../new/location" >> go.mod
|
|
|
|
```
|
|
|
|
|
2021-08-04 13:38:23 +00:00
|
|
|
> The `-replace=old[@v]=new[@v]` flag adds a replacement of the given
|
|
|
|
> module path and version pair. If the @v in old@v is omitted, a
|
|
|
|
> replacement without a version on the left side is added, which applies
|
|
|
|
> to all versions of the old module path. If the @v in new@v is omitted,
|
|
|
|
> the new path should be a local module root directory, not a module
|
|
|
|
> path. Note that -replace overrides any redundant replacements for old[@v],
|
|
|
|
> so omitting @v will drop existing replacements for specific versions
|
|
|
|
|
2021-08-04 13:23:31 +00:00
|
|
|
[^golang-godoc]: Andrew Gerrand, 31 March 2011 --- <https://blog.golang.org/godoc>
|
2021-08-04 13:38:23 +00:00
|
|
|
[^go-mod-edit]: <https://golang.org/ref/mod#go-mod-edit>
|