Beispiel #1
0
func main() {
	fmt.Println(gosample.StartMessage)

	// Make a few points
	p := geo.NewPoint(42.25, 120.2)
	p2 := geo.NewPoint(30.25, 112.2)

	// find the great circle distance between them
	dist := p.GreatCircleDistance(p2)
	fmt.Printf("great circle distance: %d\n", dist)

	sum := utils.Sum(12, 67, 6)
	fmt.Printf("sum : %d\n", sum)

	person := &models.Person{
		ID:      1,
		Name:    "John",
		Email:   "test.com",
		Age:     34,
		Address: "hoge hoge",
		Memo:    "aaaa",
	}
	b, err := json.Marshal(person)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(b))
}
Beispiel #2
0
func main() {
	sum := utils.Sum(6, 9, 6)
	fmt.Printf("sum is %d\n", sum)

	file, err := os.Create("./file.txt")
	printError(err)
	defer file.Close()

	_, err = file.Write([]byte(gosample.Message))
	printError(err)

	file, err = os.Create("./tmp/sample.json")
	printError(err)
	defer file.Close()

	p, err := json.Marshal(&models.Person{ID: 5})
	file.Write(p)

}