Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: service/datastore/pls_impl.go

Issue 1550903002: impl/memory: Fix time serialization encoding. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Deduplicate time/int conversion logic. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // HEAVILY adapted from github.com/golang/appengine/datastore 5 // HEAVILY adapted from github.com/golang/appengine/datastore
6 6
7 package datastore 7 package datastore
8 8
9 import ( 9 import (
10 "fmt" 10 "fmt"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 case reflect.Struct: 190 case reflect.Struct:
191 switch v.Type() { 191 switch v.Type() {
192 case typeOfTime: 192 case typeOfTime:
193 project = PTTime 193 project = PTTime
194 set = func(x interface{}) { v.Set(reflect.ValueO f(x)) } 194 set = func(x interface{}) { v.Set(reflect.ValueO f(x)) }
195 case typeOfGeoPoint: 195 case typeOfGeoPoint:
196 project = PTGeoPoint 196 project = PTGeoPoint
197 set = func(x interface{}) { v.Set(reflect.ValueO f(x)) } 197 set = func(x interface{}) { v.Set(reflect.ValueO f(x)) }
198 default: 198 default:
199 » » » » panic(fmt.Errorf("helper: impossible: %s", typeM ismatchReason(p.value, v))) 199 » » » » panic(fmt.Errorf("helper: impossible: %s", typeM ismatchReason(p.Value(), v)))
200 } 200 }
201 case reflect.Slice: 201 case reflect.Slice:
202 project = PTBytes 202 project = PTBytes
203 set = func(x interface{}) { 203 set = func(x interface{}) {
204 v.SetBytes(reflect.ValueOf(x).Bytes()) 204 v.SetBytes(reflect.ValueOf(x).Bytes())
205 } 205 }
206 default: 206 default:
207 » » » panic(fmt.Errorf("helper: impossible: %s", typeMismatchR eason(p.value, v))) 207 » » » panic(fmt.Errorf("helper: impossible: %s", typeMismatchR eason(p.Value(), v)))
208 } 208 }
209 209
210 pVal, err := p.Project(project) 210 pVal, err := p.Project(project)
211 if err != nil { 211 if err != nil {
212 » » » return typeMismatchReason(p.value, v) 212 » » » return typeMismatchReason(p.Value(), v)
213 } 213 }
214 if overflow != nil && overflow(pVal) { 214 if overflow != nil && overflow(pVal) {
215 return fmt.Sprintf("value %v overflows struct field of t ype %v", pVal, v.Type()) 215 return fmt.Sprintf("value %v overflows struct field of t ype %v", pVal, v.Type())
216 } 216 }
217 set(pVal) 217 set(pVal)
218 } 218 }
219 if slice.IsValid() { 219 if slice.IsValid() {
220 slice.Set(reflect.Append(slice, v)) 220 slice.Set(reflect.Append(slice, v))
221 } 221 }
222 return "" 222 return ""
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 switch val { 635 switch val {
636 case "on", "On", "true": 636 case "on", "On", "true":
637 return true, nil 637 return true, nil
638 case "off", "Off", "false": 638 case "off", "Off", "false":
639 return false, nil 639 return false, nil
640 } 640 }
641 return nil, fmt.Errorf("Toggle field has bad/missing default, go t %q", val) 641 return nil, fmt.Errorf("Toggle field has bad/missing default, go t %q", val)
642 } 642 }
643 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t , val) 643 return nil, fmt.Errorf("helper: meta field with bad type/value %s/%q", t , val)
644 } 644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698