Giter VIP home page Giter VIP logo

unnatended-test's Introduction

Hey 👋, I'm Jess! She / Her

Linkedin Protonmail

A software developer who loves cat! 🐱


GIF

🌱 Things I am currently working on:

  • 🔭 Working on @Epicurus and @WMM (Where's my music)
  • ✈️ Learning software architecture
  • 🍔 How to break user stories better
  • Working on @sumelms coop

🧰 Languages and Tools


💙 Some stats:

Jess GitHub stats

Snake animation

unnatended-test's People

Contributors

jtlimo avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

unnatended-test's Issues

Cuidado com colocar funções dentro de struct

Para ser honesto, acho que todas essas funções não precisam estar dentro da struct do server, isso apenas está deixando seu objeto demasiadamente grande, o que vai ocupar mais recurso de memória.

Você pode facilmente ter algo assim:

/// server.go
type Server struct {
	Router *mux.Router
	Db     *database.Database
}

E fazer a inicialização do restante no main:

// main.go
func main() {
    router := mux.NewRouter()
    db := database.New()
    
    // register services
    cards.Register(router)
    
    srv := Sever{
        db: db,
        router: router,
    }
    
    // all the other cool stuffs

}
// cards/service.go
func Register(r *mux.Router) {
    r.HandleFunc("/deck", createDeck).Methods("POST").Queries("cards", "{cards}")
}

func (s *Server) Setup() *mux.Router {

Está criando carta ou um deck de cartas?

Isso aqui pode ser problemático.
Saca só... Você está falando card.NewCard, certo?

Eu lendo isso entendo que você está pegando o package card e nele chamando a função NewCard, mas não é o que está acontecendo.

Você está criando um "deck de cartas" ao invés disso, e colocando o construtor dentro da struct sem motivo algum. Ou seja, cada Card sua dentro do seu []Cards tem um NewCard, que é usado para gerar um deck de cartas.

Minha recomendação é que você tire esse NewCard de da struct Card e deixa uma função normal...

func NewCards(cardCodes []string) ([]Card, error) {
    // continua igual
}

func (c *Card) NewCard(cardCodes []string) ([]Card, error) {

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.