interface{} -> any

This commit is contained in:
Evan Jarrett
2026-01-04 21:10:29 -06:00
parent aa4b32bbd6
commit a7175f9e3e
13 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -397,7 +397,7 @@ func serveRegistry(cmd *cobra.Command, args []string) error {
return
}
var metadataMap map[string]interface{}
var metadataMap map[string]any
if err := json.Unmarshal(metadataBytes, &metadataMap); err != nil {
http.Error(w, "Failed to unmarshal metadata", http.StatusInternalServerError)
return
+1 -1
View File
@@ -251,7 +251,7 @@ func (h *Handler) VerifyImage(w http.ResponseWriter, r *http.Request) {
return
}
json.NewEncoder(w).Encode(map[string]interface{}{
json.NewEncoder(w).Encode(map[string]any{
"verified": result.Verified,
"did": result.Signature.DID,
"signedAt": result.Signature.SignedAt,
+4 -4
View File
@@ -545,7 +545,7 @@ func (v *ATProtoVerifier) VerifyReference(
Name: v.name,
Type: v.Type(),
Message: fmt.Sprintf("Verified for DID %s", sigData.ATProto.DID),
Extensions: map[string]interface{}{
Extensions: map[string]any{
"did": sigData.ATProto.DID,
"handle": sigData.ATProto.Handle,
"signedAt": sigData.ATProto.SignedAt,
@@ -673,7 +673,7 @@ type ProviderRequest struct {
type ProviderResponse struct {
SystemError string `json:"system_error,omitempty"`
Responses []map[string]interface{} `json:"responses"`
Responses []map[string]any `json:"responses"`
}
func handleProvide(w http.ResponseWriter, r *http.Request) {
@@ -684,11 +684,11 @@ func handleProvide(w http.ResponseWriter, r *http.Request) {
}
// Verify each image
responses := make([]map[string]interface{}, 0, len(req.Values))
responses := make([]map[string]any, 0, len(req.Values))
for _, image := range req.Values {
result, err := verifier.Verify(context.Background(), image)
response := map[string]interface{}{
response := map[string]any{
"image": image,
"verified": false,
}
@@ -35,7 +35,7 @@ type ProviderRequest struct {
// ProviderResponse is the response format to Gatekeeper.
type ProviderResponse struct {
SystemError string `json:"system_error,omitempty"`
Responses []map[string]interface{} `json:"responses"`
Responses []map[string]any `json:"responses"`
}
// VerificationResult holds the result of verifying a single image.
@@ -110,7 +110,7 @@ func (s *Server) handleProvide(w http.ResponseWriter, r *http.Request) {
log.Printf("INFO: received verification request for %d images", len(req.Values))
// Verify each image
responses := make([]map[string]interface{}, 0, len(req.Values))
responses := make([]map[string]any, 0, len(req.Values))
for _, image := range req.Values {
result := s.verifyImage(r.Context(), image)
responses = append(responses, structToMap(result))
@@ -186,9 +186,9 @@ func (s *Server) handleReady(w http.ResponseWriter, r *http.Request) {
}
// structToMap converts a struct to a map for JSON encoding.
func structToMap(v interface{}) map[string]interface{} {
func structToMap(v any) map[string]any {
data, _ := json.Marshal(v)
var m map[string]interface{}
var m map[string]any
json.Unmarshal(data, &m)
return m
}
+1 -1
View File
@@ -196,7 +196,7 @@ type VerifierResult struct {
Name string
Type string
Message string
Extensions map[string]interface{}
Extensions map[string]any
}
```
@@ -166,7 +166,7 @@ func (v *ATProtoVerifier) VerifyReference(
Name: v.name,
Type: v.Type(),
Message: fmt.Sprintf("Successfully verified ATProto signature for DID %s", sigData.ATProto.DID),
Extensions: map[string]interface{}{
Extensions: map[string]any{
"did": sigData.ATProto.DID,
"handle": sigData.ATProto.Handle,
"signedAt": sigData.ATProto.SignedAt,
@@ -203,7 +203,7 @@ func (v *ATProtoVerifier) failureResult(message string) verifier.VerifierResult
Name: v.name,
Type: v.Type(),
Message: message,
Extensions: map[string]interface{}{
Extensions: map[string]any{
"error": message,
},
}
+5 -5
View File
@@ -339,8 +339,8 @@ func scopesMatch(stored, desired []string) bool {
// GetSessionStats returns statistics about stored OAuth sessions
// Useful for monitoring and debugging session health
func (s *OAuthStore) GetSessionStats(ctx context.Context) (map[string]interface{}, error) {
stats := make(map[string]interface{})
func (s *OAuthStore) GetSessionStats(ctx context.Context) (map[string]any, error) {
stats := make(map[string]any)
// Total sessions
var totalSessions int
@@ -392,7 +392,7 @@ func (s *OAuthStore) GetSessionStats(ctx context.Context) (map[string]interface{
// ListSessionsForMonitoring returns a list of all sessions with basic info for monitoring
// Returns: DID, session age (minutes), last update time
func (s *OAuthStore) ListSessionsForMonitoring(ctx context.Context) ([]map[string]interface{}, error) {
func (s *OAuthStore) ListSessionsForMonitoring(ctx context.Context) ([]map[string]any, error) {
rows, err := s.db.QueryContext(ctx, `
SELECT
account_did,
@@ -408,7 +408,7 @@ func (s *OAuthStore) ListSessionsForMonitoring(ctx context.Context) ([]map[strin
}
defer rows.Close()
var sessions []map[string]interface{}
var sessions []map[string]any
for rows.Next() {
var did, sessionID, createdAt, updatedAt string
var idleMinutes int
@@ -418,7 +418,7 @@ func (s *OAuthStore) ListSessionsForMonitoring(ctx context.Context) ([]map[strin
continue
}
sessions = append(sessions, map[string]interface{}{
sessions = append(sessions, map[string]any{
"did": did,
"session_id": sessionID,
"created_at": createdAt,
+1 -1
View File
@@ -95,7 +95,7 @@ func (h *DeleteManifestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusConflict)
json.NewEncoder(w).Encode(map[string]interface{}{
json.NewEncoder(w).Encode(map[string]any{
"error": "confirmation_required",
"message": "This manifest has associated tags that will also be deleted",
"tags": tags,
+4 -4
View File
@@ -32,7 +32,7 @@ func TestGetDirectoryConcurrency(t *testing.T) {
wg.Add(numGoroutines)
// Channel to collect all directory instances
instances := make(chan interface{}, numGoroutines)
instances := make(chan any, numGoroutines)
// Launch many goroutines concurrently accessing GetDirectory
for i := 0; i < numGoroutines; i++ {
@@ -48,7 +48,7 @@ func TestGetDirectoryConcurrency(t *testing.T) {
close(instances)
// Collect all instances
var dirs []interface{}
var dirs []any
for dir := range instances {
dirs = append(dirs, dir)
}
@@ -72,7 +72,7 @@ func TestGetDirectoryConcurrency(t *testing.T) {
func TestGetDirectorySequential(t *testing.T) {
t.Run("multiple calls in sequence", func(t *testing.T) {
// Get directory multiple times in sequence
dirs := make([]interface{}, 10)
dirs := make([]any, 10)
for i := 0; i < 10; i++ {
dirs[i] = GetDirectory()
}
@@ -122,7 +122,7 @@ func TestGetDirectoryRaceConditions(t *testing.T) {
var wg sync.WaitGroup
wg.Add(numGoroutines)
instances := make([]interface{}, numGoroutines)
instances := make([]any, numGoroutines)
var mu sync.Mutex
// Simulate many goroutines trying to get the directory simultaneously
+4 -4
View File
@@ -78,10 +78,10 @@ func TestFetchCaptainRecordFromXRPC(t *testing.T) {
}
// Return mock response
response := map[string]interface{}{
response := map[string]any{
"uri": "at://did:web:test-hold/io.atcr.hold.captain/self",
"cid": "bafytest123",
"value": map[string]interface{}{
"value": map[string]any{
"$type": atproto.CaptainCollection,
"owner": "did:plc:owner123",
"public": true,
@@ -281,10 +281,10 @@ func TestGetBackoffDuration(t *testing.T) {
func TestCheckReadAccess_PublicHold(t *testing.T) {
// Create mock server that returns public captain record
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
response := map[string]interface{}{
response := map[string]any{
"uri": "at://did:web:test-hold/io.atcr.hold.captain/self",
"cid": "bafytest123",
"value": map[string]interface{}{
"value": map[string]any{
"$type": atproto.CaptainCollection,
"owner": "did:plc:owner123",
"public": true, // Public hold
+1 -1
View File
@@ -513,7 +513,7 @@ func TestTokenResponse_JSONFormat(t *testing.T) {
}
// Verify JSON structure
var decoded map[string]interface{}
var decoded map[string]any
if err := json.Unmarshal(data, &decoded); err != nil {
t.Fatalf("Failed to unmarshal JSON: %v", err)
}
+3 -3
View File
@@ -207,7 +207,7 @@ func TestIssuer_Issue_ValidateToken(t *testing.T) {
}
// Parse and validate the token
token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (interface{}, error) {
token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (any, error) {
return issuer.publicKey, nil
})
if err != nil {
@@ -289,7 +289,7 @@ func TestIssuer_Issue_X5CHeader(t *testing.T) {
}
// x5c should be a slice of base64-encoded certificates
x5cSlice, ok := x5c.([]interface{})
x5cSlice, ok := x5c.([]any)
if !ok {
t.Fatal("Expected x5c to be a slice")
}
@@ -575,7 +575,7 @@ func TestIssuer_DifferentExpirations(t *testing.T) {
}
// Parse token and verify expiration
token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (interface{}, error) {
token, err := jwt.ParseWithClaims(tokenString, &Claims{}, func(token *jwt.Token) (any, error) {
return issuer.publicKey, nil
})
if err != nil {
+1 -1
View File
@@ -614,7 +614,7 @@ type mockRepo struct {
records map[string]string // key -> cid
}
func (m *mockRepo) ForEach(ctx context.Context, prefix string, fn func(string, interface{}) error) error {
func (m *mockRepo) ForEach(ctx context.Context, prefix string, fn func(string, any) error) error {
for k, v := range m.records {
if err := fn(k, v); err != nil {
if err == repo.ErrDoneIterating {