<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: samrajput1143</title>
    <description>The latest articles on DEV Community by samrajput1143 (@samrajput1143).</description>
    <link>https://dev.to/samrajput1143</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F905386%2F16eb77c3-487e-4c68-b022-05782899e372.png</url>
      <title>DEV Community: samrajput1143</title>
      <link>https://dev.to/samrajput1143</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samrajput1143"/>
    <language>en</language>
    <item>
      <title>Iterate over the field of structs and modify the value (Golang)</title>
      <dc:creator>samrajput1143</dc:creator>
      <pubDate>Mon, 08 Aug 2022 16:01:00 +0000</pubDate>
      <link>https://dev.to/samrajput1143/iterate-over-the-field-of-structs-and-modify-the-value-4ki7</link>
      <guid>https://dev.to/samrajput1143/iterate-over-the-field-of-structs-and-modify-the-value-4ki7</guid>
      <description>&lt;p&gt;&lt;code&gt;type CellMetricsEntry struct {&lt;br&gt;
    DRBUEThpDl             interface{}&lt;br&gt;
    DRBUEThpUl             interface{}&lt;br&gt;
    QosFlowPdcpPduVolumeUl interface{}&lt;br&gt;
    QosFlowPdcpPduVolumeDl interface{}&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the above structure there are more than 100 variables, but here I have taken only 4.&lt;/p&gt;

&lt;p&gt;in main function I somehow want to iterate over the field and want to modify it, as per my need.&lt;/p&gt;

&lt;p&gt;The field values can either be an int32 or float64&lt;/p&gt;

&lt;p&gt;How can i iterate over this structure field and modify the value.&lt;/p&gt;

&lt;p&gt;I want to achieve something like&lt;/p&gt;

&lt;p&gt;`var metric CellMetricsEntry&lt;/p&gt;

&lt;p&gt;for (int i=0;i&amp;lt; no_of_elements;i++)//this is pseudo code&lt;br&gt;
{&lt;br&gt;
metric[i]=value//setting  each field of struct in for loop&lt;br&gt;
//the above value I will get from some other application and this may be //either int32 or float64&lt;/p&gt;

&lt;p&gt;}`&lt;/p&gt;

&lt;p&gt;After setting all the field , I will push it to Time series database (influxdb)&lt;br&gt;
writecellMetrics_db(metric)&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
