Пример #1
0
func checkTypeSupported(typ types.Type) {
	switch typ := typ.(type) {
	case *types.Int:
		switch typ.Width() {
		case 1, 8, 16, 32, 64:
			// all good
		default:
			goto unsupported
		}

	case *types.Array:
		checkTypeSupported(typ.Element())

	case *types.Struct:
		for _, field := range typ.Fields() {
			checkTypeSupported(field)
		}
	}

	return

unsupported:
	panic(fmt.Sprintf("unsupported type: %s", typ))
}