How do I convert drupal_goto to 301?
Looks like you're mistaking the function definition for an implementation example.

The function definition describes the arguments to use, but it's not a literal example of how to call it.

So when you want to use the drupal_goto() function, instead of this:

drupal_goto($path, array $options = array(), $http_response_code = 302);


It should look more like this:

drupal_goto($path, array(), 301);