Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sylhare/go
Experiments on Go
https://github.com/sylhare/go
Last synced: about 2 months ago
JSON representation
Experiments on Go
- Host: GitHub
- URL: https://github.com/sylhare/go
- Owner: sylhare
- License: gpl-3.0
- Created: 2018-11-17T21:02:16.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-08T14:31:59.000Z (about 2 months ago)
- Last Synced: 2024-11-08T15:31:20.167Z (about 2 months ago)
- Language: Go
- Size: 70.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go
Experiments on Go
## Go-lang
Go is an open source programming language.
To install it, you can either download it from [golang.org](https://golang.org/) or use brew:```bash
brew install golang
...
go version
>> go version go1.11.2 darwin/amd64
```## Introduction
### Run your script
Run you script `hello.go` with:
```bash
go run pkg/examples/hello.go
>> Hello, World!
```### Install a Go script
Install it in your `$GOPATH/bin` with:
```bash
go install hello.go
```You need to set your own `$GOPATH` for it to work.
Check `setup.sh` to see which path to export, Add the change to your `.bashrc` to make it permanent.### Create a Go module
Run the following command to create a new module:
```bash
go mod init
```This will create a `go.mod` file in the current directory.
### Dependency management
To add a dependency, run:
```bash
go get
```This will add the package to the `go.mod` file.
To install all dependencies, and clean up the `go.mod` file, run:```bash
go mod tidy
```You can also use `go mod download` which will download all dependencies in the cache.
### Run a unit test
Run unit tests:
```bash
go test ./...
```This should run all the tests in the current directory and subdirectories.
## Sources
Here are a couple of useful links:
- [How to write Go code](https://golang.org/doc/code.html#Workspaces)
- [Interactive Go tutorial](https://tour.golang.org/welcome/1)