@@ -46,7 +46,7 @@ func (e *Element) Equals(target *Element) bool {
4646func (e * Element ) String () string {
4747 var tagName string
4848 if tagInfo , err := tag .Find (e .Tag ); err == nil {
49- tagName = tagInfo .Name
49+ tagName = tagInfo .Keyword
5050 }
5151 return fmt .Sprintf ("[\n Tag: %s\n Tag Name: %s\n VR: %s\n VR Raw: %s\n VL: %d\n Value: %s\n ]\n \n " ,
5252 e .Tag .String (),
@@ -91,7 +91,7 @@ type Value interface {
9191 ValueType () ValueType
9292 // GetValue returns the underlying value that this Value holds. What type is returned here can be determined exactly
9393 // from the ValueType() of this Value (see the ValueType godoc).
94- GetValue () interface {} // TODO: rename to Get to read cleaner
94+ GetValue () any // TODO: rename to Get to read cleaner
9595 String () string
9696 MarshalJSON () ([]byte , error )
9797 // Equals returns true if this value equals the input Value.
@@ -107,7 +107,7 @@ type Value interface {
107107// Acceptable types: []int, []string, []byte, []float64, PixelDataInfo,
108108// [][]*Element (represents a sequence, which contains several
109109// items which each contain several elements).
110- func NewValue (data interface {} ) (Value , error ) {
110+ func NewValue (data any ) (Value , error ) {
111111 switch data .(type ) {
112112 case []int :
113113 return & intsValue {value : data .([]int )}, nil
@@ -127,11 +127,11 @@ func NewValue(data interface{}) (Value, error) {
127127 }
128128 return & sequencesValue {value : sequenceItems }, nil
129129 default :
130- return nil , ErrorUnexpectedDataType
130+ return nil , fmt . Errorf ( "NewValue: unexpected data type %T: %w" , data , ErrorUnexpectedDataType )
131131 }
132132}
133133
134- func mustNewValue (data interface {} ) Value {
134+ func mustNewValue (data any ) Value {
135135 v , err := NewValue (data )
136136 if err != nil {
137137 panic (err )
@@ -142,13 +142,15 @@ func mustNewValue(data interface{}) Value {
142142// NewElement creates a new DICOM Element with the supplied tag and with a value
143143// built from the provided data. The data can be one of the types that is
144144// acceptable to NewValue.
145- func NewElement (t tag.Tag , data interface {} ) (* Element , error ) {
145+ func NewElement (t tag.Tag , data any ) (* Element , error ) {
146146 tagInfo , err := tag .Find (t )
147147 if err != nil {
148148 return nil , err
149149 }
150- rawVR := tagInfo .VR
151-
150+ rawVR := tagInfo .VRs [0 ]
151+ if t == tag .PixelData {
152+ rawVR = "OW"
153+ }
152154 value , err := NewValue (data )
153155 if err != nil {
154156 return nil , err
@@ -162,15 +164,15 @@ func NewElement(t tag.Tag, data interface{}) (*Element, error) {
162164 }, nil
163165}
164166
165- func mustNewElement (t tag.Tag , data interface {} ) * Element {
167+ func mustNewElement (t tag.Tag , data any ) * Element {
166168 elem , err := NewElement (t , data )
167169 if err != nil {
168170 log .Panic (err )
169171 }
170172 return elem
171173}
172174
173- func mustNewPrivateElement (t tag.Tag , rawVR string , data interface {} ) * Element {
175+ func mustNewPrivateElement (t tag.Tag , rawVR string , data any ) * Element {
174176 value , err := NewValue (data )
175177 if err != nil {
176178 log .Panic (fmt .Errorf ("error creating value: %w" , err ))
@@ -215,9 +217,9 @@ type bytesValue struct {
215217 value []byte
216218}
217219
218- func (b * bytesValue ) isElementValue () {}
219- func (b * bytesValue ) ValueType () ValueType { return Bytes }
220- func (b * bytesValue ) GetValue () interface {} { return b .value }
220+ func (b * bytesValue ) isElementValue () {}
221+ func (b * bytesValue ) ValueType () ValueType { return Bytes }
222+ func (b * bytesValue ) GetValue () any { return b .value }
221223func (b * bytesValue ) String () string {
222224 return fmt .Sprintf ("%v" , b .value )
223225}
@@ -240,9 +242,9 @@ type stringsValue struct {
240242 value []string
241243}
242244
243- func (s * stringsValue ) isElementValue () {}
244- func (s * stringsValue ) ValueType () ValueType { return Strings }
245- func (s * stringsValue ) GetValue () interface {} { return s .value }
245+ func (s * stringsValue ) isElementValue () {}
246+ func (s * stringsValue ) ValueType () ValueType { return Strings }
247+ func (s * stringsValue ) GetValue () any { return s .value }
246248func (s * stringsValue ) String () string {
247249 return fmt .Sprintf ("%v" , s .value )
248250}
@@ -271,9 +273,9 @@ type intsValue struct {
271273 value []int
272274}
273275
274- func (i * intsValue ) isElementValue () {}
275- func (i * intsValue ) ValueType () ValueType { return Ints }
276- func (i * intsValue ) GetValue () interface {} { return i .value }
276+ func (i * intsValue ) isElementValue () {}
277+ func (i * intsValue ) ValueType () ValueType { return Ints }
278+ func (i * intsValue ) GetValue () any { return i .value }
277279func (i * intsValue ) String () string {
278280 return fmt .Sprintf ("%v" , i .value )
279281}
@@ -302,9 +304,9 @@ type floatsValue struct {
302304 value []float64
303305}
304306
305- func (f * floatsValue ) isElementValue () {}
306- func (f * floatsValue ) ValueType () ValueType { return Floats }
307- func (f * floatsValue ) GetValue () interface {} { return f .value }
307+ func (f * floatsValue ) isElementValue () {}
308+ func (f * floatsValue ) ValueType () ValueType { return Floats }
309+ func (f * floatsValue ) GetValue () any { return f .value }
308310func (f * floatsValue ) String () string {
309311 return fmt .Sprintf ("%v" , f .value )
310312}
@@ -343,7 +345,7 @@ func (s *SequenceItemValue) ValueType() ValueType { return SequenceItem }
343345// GetValue returns the underlying value that this Value holds. What type is
344346// returned here can be determined exactly from the ValueType() of this Value
345347// (see the ValueType godoc).
346- func (s * SequenceItemValue ) GetValue () interface {} { return s .elements }
348+ func (s * SequenceItemValue ) GetValue () any { return s .elements }
347349
348350// String is used to get a string representation of this struct.
349351func (s * SequenceItemValue ) String () string {
@@ -377,9 +379,9 @@ type sequencesValue struct {
377379 value []* SequenceItemValue
378380}
379381
380- func (s * sequencesValue ) isElementValue () {}
381- func (s * sequencesValue ) ValueType () ValueType { return Sequences }
382- func (s * sequencesValue ) GetValue () interface {} { return s .value }
382+ func (s * sequencesValue ) isElementValue () {}
383+ func (s * sequencesValue ) ValueType () ValueType { return Sequences }
384+ func (s * sequencesValue ) GetValue () any { return s .value }
383385func (s * sequencesValue ) String () string {
384386 // TODO: consider adding more sophisticated formatting
385387 return fmt .Sprintf ("%+v" , s .value )
@@ -438,9 +440,9 @@ type pixelDataValue struct {
438440 PixelDataInfo
439441}
440442
441- func (p * pixelDataValue ) isElementValue () {}
442- func (p * pixelDataValue ) ValueType () ValueType { return PixelData }
443- func (p * pixelDataValue ) GetValue () interface {} { return p .PixelDataInfo }
443+ func (p * pixelDataValue ) isElementValue () {}
444+ func (p * pixelDataValue ) ValueType () ValueType { return PixelData }
445+ func (p * pixelDataValue ) GetValue () any { return p .PixelDataInfo }
444446func (p * pixelDataValue ) String () string {
445447 if len (p .Frames ) == 0 {
446448 return "empty pixel data"
@@ -528,7 +530,7 @@ func MustGetPixelDataInfo(v Value) PixelDataInfo {
528530
529531// allValues is used for tests that need to pass in instances of the unexported
530532// value structs to cmp.AllowUnexported.
531- var allValues = []interface {} {
533+ var allValues = []any {
532534 floatsValue {},
533535 intsValue {},
534536 stringsValue {},
0 commit comments