Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercício: Capítulo 24, Exercício 1 (Nível: 11) #73

Open
vkorbes opened this issue Sep 30, 2020 · 1 comment
Open

Exercício: Capítulo 24, Exercício 1 (Nível: 11) #73

vkorbes opened this issue Sep 30, 2020 · 1 comment

Comments

@vkorbes
Copy link
Owner

vkorbes commented Sep 30, 2020

Exercício: Capítulo 24, Exercício 1 (Nível: 11)

Link para o vídeo:

Use esta thread para compartilhar sua solução, discutir o exercício com os colegas e pedir ajuda caso tenha dificuldades!

@an4kein
Copy link

an4kein commented Mar 24, 2021

https://play.golang.org/p/BhRs2d3oIQv

package main

/* - Utilizando este código: https://play.golang.org/p/3W69TH4nON​
- ...remova o underscore e verifique e lide com o erro de maneira apropriada. */

import (
	"encoding/json"
	"fmt"
	"log"
)

type person struct {
	First   string
	Last    string
	Sayings []string
}

func main() {
	p1 := person{
		First:   "James",
		Last:    "Bond",
		Sayings: []string{"Shaken, not stirred", "Any last wishes?", "Never say never"},
	}

	bs, err := json.Marshal(p1)
	if err != nil {
		log.Println("Exist error", err)
	}
	fmt.Println(string(bs))
}

Output

{"First":"James","Last":"Bond","Sayings":["Shaken, not stirred","Any last wishes?","Never say never"]}

Program exited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants