blob: b9e6caca03a9d48c2c2ff169cd2b41bafad1a246 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// +build !build_with_native_toolchain
package main
import (
"errors"
lib "fidl/fidl/test/enumstrictflexible"
)
// [START contents]
func writer(s string) lib.Color {
switch {
case s == "blue":
return lib.ColorBlue
case s == "red":
return lib.ColorRed
default:
return lib.Color_Unknown
}
}
func reader(color lib.Color) (string, error) {
if color.IsUnknown() {
return "unknown", nil
}
switch color {
case lib.ColorBlue:
return "blue", nil
case lib.ColorRed:
return "red", nil
default:
return "", errors.New("invalid color enum")
}
}
// [END contents]
func main() {}