Short examples of common anti-patterns in Go Web Applications.

Owner
Three Dots Labs
Golang, Domain-Driven Design and Continuous Delivery.
Three Dots Labs
Similar Resources

Extract structured data from web sites. Web sites scraping.

Extract structured data from web sites. Web sites scraping.

Dataflow kit Dataflow kit ("DFK") is a Web Scraping framework for Gophers. It extracts data from web pages, following the specified CSS Selectors. You

Jan 7, 2023

記帳-PWA-web-app (Bookkeeping-PWA-web-app)

記帳-PWA-web-app (Bookkeeping-PWA-web-app)

GoKeep (bookkeeping web app) 記帳-PWA-web-app (Bookkeeping-PWA-web-app) demo link : https://bookkepping.herokuapp.com/ 測試用帳密 : tester002 , tester002 (亦可

Jan 31, 2022

log4jScanner: provides you with the ability to scan internal (only) subnets for vulnerable log4j web servicelog4jScanner: provides you with the ability to scan internal (only) subnets for vulnerable log4j web service

log4jScanner: provides you with the ability to scan internal (only) subnets for vulnerable log4j web servicelog4jScanner: provides you with the ability to scan internal (only) subnets for vulnerable log4j web service

log4jScanner Goals This tool provides you with the ability to scan internal (only) subnets for vulnerable log4j web services. It will attempt to send

Jan 5, 2023

Web terminal - A (unsafe) technical demo to export a shell to web browser

Web terminal - A (unsafe) technical demo to export a shell to web browser

Web Terminal A (unsafe) technical demo to export a shell to web browser. This pr

Dec 27, 2022

Go-web-scaffold - A simple scaffold for building web app quickly

Go-web-scaffold A simple scaffold for building web app quickly. features This sc

Jan 21, 2022

Nada is a JS runtime, just like Nodejs. The difference is that Nada allows JS developers to easily achieve millions of concurrent applications.

Nada is a JS runtime, just like Nodejs. The difference is that Nada allows JS developers to easily achieve millions of concurrent applications. It also adds some new enhancements to THE JS syntax (types, interfaces, generics) that fundamentally address JS's perennial complaints.

Jul 11, 2022

Colonies is a generic framework for implementing next-generation distributed applications and systems

Colonies is a generic framework for implementing next-generation distributed applications and systems

Colonies is a generic framework for implementing next-generation distributed applications and systems. It can be used as a building block for grid computing or edge computing, e.g. implement a meta operating system or cloud-of-cloud platform that combines many execution environments into a new virtual computing environment that can be controlled using an single unified API.

Nov 14, 2022

IP geolocation web server

freegeoip NOTE: as of April 2018 this repository is no longer active. Please visit https://github.com/apilayer/freegeoip/ for the current version. Thi

Dec 26, 2022

Polite, slim and concurrent web crawler.

gocrawl gocrawl is a polite, slim and concurrent web crawler written in Go. For a simpler yet more flexible web crawler written in a more idiomatic Go

Dec 31, 2022
Comments
  • Add more idiomatic Go implementation

    Add more idiomatic Go implementation

    Hey, thank you for writing a good article! What do you think about this small improvement?

    Update: In Go, if there is an error the main result is undefined and could be nil, but if there was no error the result should always be valid, even if it's empty.

    In my opinion you should never return Unknown if there's an error.

  • Serialization of Enum Patterns

    Serialization of Enum Patterns

    Hi @m110 --

    Thought this probably the best way to raise some feedback on your safer enums post & code. The article does not mention serialisation of enums (e.g. to/from JSON, etc). Your recommended struct pattern has a drawback here in that with private members any serialisation will convert the value back to its sentinel zero value.

    While the safety of serialising enum without explicit custom marshalling functions is debatable, other enum options like an simple int do serialise OK by default so think it's an angle that would be worth calling out.

  • Fix typo in test

    Fix typo in test

    Current test was a duplicate of the one above, re-testing the first user instead of the one freshly pulled by ID.

    Tests still passing:

    ⇒ make test
    PASS
    ok  	github.com/ThreeDotsLabs/go-web-app-antipatterns/tests	0.226s
    
  • Enums: using const instead of var?

    Enums: using const instead of var?

    I continue to write here coming from the post's comment.

    I think it's a great idea to use functions because I can reduce the code noticeably having even more security (because I don't use simple strings anymore).

    type StateEnum struct {
     	slug string
     }
     
    -func (o StateEnum) Is(s string) bool {
    -	return o.slug == s
    +func (o StateEnum) Is(s StateEnum) bool {
    +	return o == s
     }
     
     func (o StateEnum) String() string {
     	return o.slug
     }
     
    -const (
    -	Draft     = "DRAFT"
    -	Completed = "COMPLETED"
    -	Approved  = "APPROVED"
    -	Rejected  = "REJECTED"
    -)
    -
    -func NewStateEnumFromString(s string) StateEnum {
    -	switch s {
    -	case Draft:
    -		return StateEnum{Draft}
    -	case Completed:
    -		return StateEnum{Completed}
    -	case Approved:
    -		return StateEnum{Approved}
    -	case Rejected:
    -		return StateEnum{Rejected}
    -	default:
    -		panic("unknown StateEnum")
    -	}
    -}
    +func Draft() StateEnum     { return StateEnum{"DRAFT"} }
    +func Completed() StateEnum { return StateEnum{"COMPLETED"} }
    +func Approved() StateEnum  { return StateEnum{"APPROVED"} }
    +func Rejected() StateEnum  { return StateEnum{"REJECTED"} }
    

    But, there is a but.

    In some parts of my codebase I need to marshal and unmarshal from string.

    So I need again the func NewStateEnumFromString(), right?

longurl is a self-hosted short url service.

longurl Introduction longurl is a self-hosted short url service. Try It Out curl -H "Content-Type:application/json" -X POST --data '{"url": "https://g

Oct 24, 2022
Create a short link

Shortlink using a GCP Cloud Run Serverless example Make a Dir: mkdir shortlink && cd shortlink Clone: git clone https://github.com/tonnytg/shortlink.

Nov 26, 2021
This is a simple URL shortner Go Lang client that uses the short.io

Opinionated URL Shortner Client This is a simple URL shortner Go Lang client that uses the short.io TL;DR One liner (for my use case) ./short.io -key

Feb 11, 2022
Short url backend - Go musthave shortener tpl

go-musthave-shortener-tpl Шаблон репозитория для практического трека «Go в веб-р

Feb 15, 2022
Example patterns for distributed service

Cloud Native Tulisan ini akan mengulas hasil pembelajaran dari beberapa sumber #learn-from-books. Dan terinspirasi dari obrolan The Pursuit of Product

Jan 30, 2022
Concurrency Lab examples on Go
Concurrency Lab examples on Go

Concurrency Lab 1 If you're stuck look at examples on Go by Example Using the lab sheet There are two ways to use the lab sheet, you can either: creat

Oct 22, 2021
Golang/Gin codebase containing real world examples that adheres to the RealWorld spec and API.
 Golang/Gin codebase containing real world examples that adheres to the RealWorld spec and API.

Golang/Gin codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API. This codebase was

Dec 3, 2021
staticfiles is an asset manager for a web applications written in Go.

Overview staticfiles is an asset manager for a web applications written in Go. It collects asset files (CSS, JS, images, etc.) from a different locati

Dec 7, 2022
Broilerplate - A template project for new Go web backend applications
Broilerplate - A template project for new Go web backend applications

Broilerplate A template project for new Go web backend applications. Can be used

Mar 28, 2022
A new way to create web applications using go and sdf framework.

SDF GO A new way to create web applications using go and sdf framework Explore the docs » View Demo · Report Bug · Request Feature Table of Contents A

Sep 27, 2022