Go Web App Anti-Patterns
This repository contains short examples of common anti-patterns in Go Web Applications.
For complete description, see Common Anti-Patterns in Go Web Applications.
This repository contains short examples of common anti-patterns in Go Web Applications.
For complete description, see Common Anti-Patterns in Go Web Applications.
Dataflow kit Dataflow kit ("DFK") is a Web Scraping framework for Gophers. It extracts data from web pages, following the specified CSS Selectors. You
GoKeep (bookkeeping web app) 記帳-PWA-web-app (Bookkeeping-PWA-web-app) demo link : https://bookkepping.herokuapp.com/ 測試用帳密 : tester002 , tester002 (亦可
log4jScanner Goals This tool provides you with the ability to scan internal (only) subnets for vulnerable log4j web services. It will attempt to send
Web Terminal A (unsafe) technical demo to export a shell to web browser. This pr
Go-web-scaffold A simple scaffold for building web app quickly. features This sc
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.
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.
freegeoip NOTE: as of April 2018 this repository is no longer active. Please visit https://github.com/apilayer/freegeoip/ for the current version. Thi
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
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.
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.
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
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 Introduction longurl is a self-hosted short url service. Try It Out curl -H "Content-Type:application/json" -X POST --data '{"url": "https://g
Shortlink using a GCP Cloud Run Serverless example Make a Dir: mkdir shortlink && cd shortlink Clone: git clone https://github.com/tonnytg/shortlink.
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
go-musthave-shortener-tpl Шаблон репозитория для практического трека «Go в веб-р
Cloud Native Tulisan ini akan mengulas hasil pembelajaran dari beberapa sumber #learn-from-books. Dan terinspirasi dari obrolan The Pursuit of Product
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
Golang/Gin codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API. This codebase was
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
Broilerplate A template project for new Go web backend applications. Can be used
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