| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 //go:generate stringer -type=Toggle |
| 6 |
| 5 package datastore | 7 package datastore |
| 6 | 8 |
| 7 import ( | |
| 8 "fmt" | |
| 9 ) | |
| 10 | |
| 11 // GeoPoint represents a location as latitude/longitude in degrees. | 9 // GeoPoint represents a location as latitude/longitude in degrees. |
| 12 // | 10 // |
| 13 // You probably shouldn't use these, but their inclusion here is so that the | 11 // You probably shouldn't use these, but their inclusion here is so that the |
| 14 // datastore service can interact (and round-trip) correctly with other | 12 // datastore service can interact (and round-trip) correctly with other |
| 15 // datastore API implementations. | 13 // datastore API implementations. |
| 16 type GeoPoint struct { | 14 type GeoPoint struct { |
| 17 Lat, Lng float64 | 15 Lat, Lng float64 |
| 18 } | 16 } |
| 19 | 17 |
| 20 // Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, | 18 // Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 42 // Toggle is a tri-state boolean (Auto/True/False), which allows structs | 40 // Toggle is a tri-state boolean (Auto/True/False), which allows structs |
| 43 // to control boolean flags for metadata in a non-ambiguous way. | 41 // to control boolean flags for metadata in a non-ambiguous way. |
| 44 type Toggle byte | 42 type Toggle byte |
| 45 | 43 |
| 46 // These are the allowed values for Toggle. Any other values are invalid. | 44 // These are the allowed values for Toggle. Any other values are invalid. |
| 47 const ( | 45 const ( |
| 48 Auto Toggle = iota | 46 Auto Toggle = iota |
| 49 On | 47 On |
| 50 Off | 48 Off |
| 51 ) | 49 ) |
| 52 | |
| 53 func (b Toggle) String() string { | |
| 54 switch b { | |
| 55 case Auto: | |
| 56 return "Auto" | |
| 57 case On: | |
| 58 return "On" | |
| 59 case Off: | |
| 60 return "Off" | |
| 61 default: | |
| 62 return fmt.Sprintf("UNKNOWN_Toggle(%d)", b) | |
| 63 } | |
| 64 } | |
| OLD | NEW |