@@ -21,7 +21,7 @@ func (cookies Cookies) String() string {
2121
2222 displayLimit := 3
2323
24- for i , item := range cookies {
24+ for i , item := range cookies [: min ( len ( cookies ), displayLimit )] {
2525 if i > 0 {
2626 buffer .WriteString (",\n " )
2727 }
@@ -96,18 +96,18 @@ func (cookies *Cookies) Set(value string) error {
9696 return nil
9797}
9898
99- func (cookies * Cookies ) AppendByKey (key string , value string ) {
100- if existingValue := cookies .GetValue (key ); existingValue != nil {
101- * cookies = append (* cookies , KeyValue [ string , [] string ]{ Key : key , Value : append ( existingValue , value )} )
99+ func (cookies * Cookies ) AppendByKey (key , value string ) {
100+ if item := cookies .GetValue (key ); item != nil {
101+ * item = append (* item , value )
102102 } else {
103103 * cookies = append (* cookies , KeyValue [string , []string ]{Key : key , Value : []string {value }})
104104 }
105105}
106106
107- func (cookies * Cookies ) GetValue (key string ) []string {
108- for _ , cookie := range * cookies {
109- if cookie .Key == key {
110- return cookie .Value
107+ func (cookies Cookies ) GetValue (key string ) * []string {
108+ for i := range cookies {
109+ if cookies [ i ] .Key == key {
110+ return & cookies [ i ] .Value
111111 }
112112 }
113113 return nil
0 commit comments