Giter VIP home page Giter VIP logo

go_playground's Introduction

  ____         ____  _             
 / ___| ___   |  _ \| | __ _ _   _ 
| |  _ / _ \  | |_) | |/ _` | | | |
| |_| | (_) | |  __/| | (_| | |_| |
 \____|\___/  |_|   |_|\__,_|\__, |
                             |___/ 

GO Playground Project

This is the playground project to start with some go learning.

Setup Go

Depending on your environment install go with

OS Command
Arch-based sudo pacman -S go
Debian-based sudo apt install golang-go
MacOS brew install go

Check if installation was successful with go version.

Ensure to have a GOPATH env variable set to $HOME/go and $GOPATH/bin in your PATH env variable. The directory $HOME/go should be created automatically by the go installation. For instance you can put the following lines in your .bashrc or .zshrc file:

export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin

Install a linter

Install a linter with go install golang.org/x/lint/golint@latest.

Simple Hello World

Create a new directory example1.

take example1
go mod init example1

# For production ready code:
go mod init github.com/PRODYNA/pan_deploy

Write your code in example1.go:

package main

import "fmt"

func main() {
    message := "Hello, world!"
    fmt.Printf("Message from Example1: %s\n", message)
}

Run it with go run example1.go. To create an executable example1 run go build example1.go.

Provide a Makefile to build and run the project:

.DEFAULT_GOAL := build

fmt:
	@go fmt ./...
.PHONY: fmt

lint: fmt
	golint ./...
.PHONY: lint

vet: fmt
	go vet ./...
.PHONY: vet

build: vet
	go build -o example1
.PHONY: build

Execute it with make.

Find a module

Visit pkg.go.dev to find a module.

Domain-Driven Design Project Structure

DDD project structure

Source: GopherCon 2018 Kat Zien How Do You Structure Your Go Apps (https://www.youtube.com/watch?v=oL6JBUk6tj0)

go_playground's People

Contributors

mopore avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.