Go構造体サンプル

Go構造体サンプル

  • Goの構造体はC言語のtypedef structと似ている
package main

import "fmt"

type NoRelateDurg struct {
    DrugCode string
    DrugName string
}

func (drug *NoRelateDurg) DebugInfo() string {
    return drug.DrugCode + ":" + drug.DrugName
}

func main() {
    drug := NoRelateDurg{"123456", "ロキソニン"}
    fmt.Println(drug.DebugInfo())
}