Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(913)

Delta Between Two Patch Sets: src/pkg/asn1/marshal.go

Issue 4645069: code review 4645069: reflect: support for struct tag use by multiple packages (Closed)
Left Patch Set: Created 13 years, 8 months ago
Right Patch Set: diff -r dd7479dd252a https://go.googlecode.com/hg/ Created 13 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/asn1/asn1_test.go ('k') | src/pkg/asn1/marshal_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package asn1 5 package asn1
6 6
7 import ( 7 import (
8 "big" 8 "big"
9 "bytes" 9 "bytes"
10 "fmt" 10 "fmt"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 _, err = out.Write(stripTagAndLength(bytes)) 406 _, err = out.Write(stripTagAndLength(bytes))
407 return 407 return
408 } else { 408 } else {
409 startingField = 1 409 startingField = 1
410 } 410 }
411 } 411 }
412 412
413 for i := startingField; i < t.NumField(); i++ { 413 for i := startingField; i < t.NumField(); i++ {
414 var pre *forkableWriter 414 var pre *forkableWriter
415 pre, out = out.fork() 415 pre, out = out.fork()
416 » » » err = marshalField(pre, v.Field(i), parseFieldParameters (t.Field(i).Tag)) 416 » » » err = marshalField(pre, v.Field(i), parseFieldParameters (t.Field(i).Tag.Get("asn1")))
417 if err != nil { 417 if err != nil {
418 return 418 return
419 } 419 }
420 } 420 }
421 return 421 return
422 case reflect.Slice: 422 case reflect.Slice:
423 sliceType := v.Type() 423 sliceType := v.Type()
424 if sliceType.Elem().Kind() == reflect.Uint8 { 424 if sliceType.Elem().Kind() == reflect.Uint8 {
425 bytes := make([]byte, v.Len()) 425 bytes := make([]byte, v.Len())
426 for i := 0; i < v.Len(); i++ { 426 for i := 0; i < v.Len(); i++ {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 var out bytes.Buffer 535 var out bytes.Buffer
536 v := reflect.ValueOf(val) 536 v := reflect.ValueOf(val)
537 f := newForkableWriter() 537 f := newForkableWriter()
538 err := marshalField(f, v, fieldParameters{}) 538 err := marshalField(f, v, fieldParameters{})
539 if err != nil { 539 if err != nil {
540 return nil, err 540 return nil, err
541 } 541 }
542 _, err = f.writeTo(&out) 542 _, err = f.writeTo(&out)
543 return out.Bytes(), nil 543 return out.Bytes(), nil
544 } 544 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b