# GetOrSetSecret

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`UserSecretsManager`](/reference/api/go/aspire.hosting/usersecretsmanager.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Gets a secret value if it exists in configuration, or sets it to the provided value if it does not.

## Definition

```go
func (UserSecretsManager) GetOrSetSecret(
    resourceBuilder Resource,
    name string,
    value string,
) error
```

## Parameters

- `resourceBuilder` ([`Resource`](/reference/api/go/aspire.hosting/resource.md)) -- A resource builder from the target application.
- `name` (`string`) -- The secret name.
- `value` (`string`) -- The value to persist when the secret is missing.

## Returns

`error`

Returns `error`.

## Applies to

- [`UserSecretsManager`](/reference/api/go/aspire.hosting/usersecretsmanager.md)
