title: Is it possible to delete a field of a struct value at runtime?
body: <p>I have the following struct:</p>
  
  <pre><code>type Record struct {
    Id     string   `json:"id"`
    ApiKey string   `json:"apiKey"`
    Body   []string `json:"body"`
    Type   string   `json:"type"`
  }
  </code></pre>
  
  <p>Which is a Blueprint of a dynamoDB table. And I need somehow, delete the ApiKey, after using to check if the user has access to the giving record. Explaining:</p>
  
  <p>I have and endpoint in my API where the user can send a <code>id</code> to get a item, but he needs to have access to the ID and the ApiKey (I'm using Id (uuid) + ApiKey) to create unique items.</p>
  
  <p>How I'm doing:</p>
  
  <pre><code> func getExtraction(id string, apiKey string) (Record, error) {
      svc := dynamodb.New(cfg)
  
      req := svc.GetItemRequest(&amp;dynamodb.GetItemInput{
        TableName: aws.String(awsEnv.Dynamo_Table),
        Key: map[string]dynamodb.AttributeValue{
          "id": {
            S: aws.String(id),
          },
        },
      })
  
      result, err := req.Send()
      if err != nil {
        return Record{}, err
      }
  
      record := Record{}
      err = dynamodbattribute.UnmarshalMap(result.Item, &amp;record)
      if err != nil {
        return Record{}, err
      }
  
      if record.ApiKey != apiKey {
        return Record{}, fmt.Errorf("item %d not found", id)
      }
      // Delete ApiKey from record
      return record, nil
    }
  </code></pre>
  
  <p>After checking if the ApiKey is equal to the provided <code>apiKey</code>, I want to delete the <code>ApiKey</code> from <code>record</code>, but unfortunately that's not possible using <code>delete</code>.</p>
  
  <p>Thank you.</p>