Go Composite Types (Map, Struct) , Print Struct Variants | Golang 101 Tutorial

Поделиться
HTML-код
  • Опубликовано: 24 авг 2024
  • In this video, we will continue looking at Composite types in Go. We will see Map, Struct, Nested Structs as well as various ways to Print Struct on console using Printf, JSON Marshal, JSON Marsha Indent etc.
    #golang #golangtutorial #developers #google #tutorial #map #structs #learn

Комментарии • 2

  • @arozendojr
    @arozendojr 2 года назад

    I have a question about anatomy ,pakage in go
    Is there any logic or convention where to put the structs?
    One struct per file like java ?
    Does the organization of *.go content have a pattern within a package?
    anatomy using DDD is the same thing?

    • @durgadaskamath
      @durgadaskamath  2 года назад +1

      Hey, there isn't any convention as such. But in a project, I prefer the approach we take in a nodejs project for e.g lets say we have User model and Product model, i would organize them as below:
      models/user.go
      models/product.go
      and within the user.go, I would define the struct
      type User struct {
      ID
      Name string
      }
      Not sure if this answers your question but I will be having videos on the project structure , best practices in future videos in this series.