Repository: google/go-github
File: github/messages.go (Go)

Code before:
		"public":                         &PublicEvent{},
		"pull_request":                   &PullRequestEvent{},
		"pull_request_review":            &PullRequestReviewEvent{},
		"pull_request_review_comment":    &PullRequestReviewCommentEvent{},
		"pull_request_review_thread":     &PullRequestReviewThreadEvent{},
		"pull_request_target":            &PullRequestTargetEvent{},
		"push":                           &PushEvent{},
		"repository":                     &RepositoryEvent{},
		"repository_dispatch":            &RepositoryDispatchEvent{},
		"repository_import":              &RepositoryImportEvent{},
		"repository_vulnerability_alert": &RepositoryVulnerabilityAlertEvent{},
		"release":                        &ReleaseEvent{},
		"secret_scanning_alert":          &SecretScanningAlertEvent{},
		"security_advisory":              &SecurityAdvisoryEvent{},
		"security_and_analysis":          &SecurityAndAnalysisEvent{},
		"star":                           &StarEvent{},
		"status":                         &StatusEvent{},
		"team":                           &TeamEvent{},
		"team_add":                       &TeamAddEvent{},
		"user":                           &UserEvent{},
		"watch":                          &WatchEvent{},
		"workflow_dispatch":              &WorkflowDispatchEvent{},
		"workflow_job":                   &WorkflowJobEvent{},
		"workflow_run":                   &WorkflowRunEvent{},
	}
	// forward mapping of event types to the sting names of the structs
	messageToTypeName = make(map[string]string, len(eventTypeMapping))
	// Inverse map of the above
	typeToMessageMapping = make(map[string]string, len(eventTypeMapping))
)

func init() {
	for k, v := range eventTypeMapping {
		typename := reflect.TypeOf(v).Elem().Name()
		messageToTypeName[k] = typename
		typeToMessageMapping[typename] = k
	}
}

// genMAC generates the HMAC signature for a message provided the secret key
// and hashFunc.
func genMAC(message, key []byte, hashFunc func() hash.Hash) []byte {
	mac := hmac.New(hashFunc, key)
	mac.Write(message)
	return mac.Sum(nil)
}

// checkMAC reports whether messageMAC is a valid HMAC tag for message.
func checkMAC(message, messageMAC, key []byte, hashFunc func() hash.Hash) bool {
	expectedMAC := genMAC(message, key, hashFunc)
	return hmac.Equal(messageMAC, expectedMAC)

Review comment (suggestion):
```suggestion
	// forward mapping of event types to the string names of the structs
```

Code after:
		"public":                         &PublicEvent{},
		"pull_request":                   &PullRequestEvent{},
		"pull_request_review":            &PullRequestReviewEvent{},
		"pull_request_review_comment":    &PullRequestReviewCommentEvent{},
		"pull_request_review_thread":     &PullRequestReviewThreadEvent{},
		"pull_request_target":            &PullRequestTargetEvent{},
		"push":                           &PushEvent{},
		"repository":                     &RepositoryEvent{},
		"repository_dispatch":            &RepositoryDispatchEvent{},
		"repository_import":              &RepositoryImportEvent{},
		"repository_vulnerability_alert": &RepositoryVulnerabilityAlertEvent{},
		"release":                        &ReleaseEvent{},
		"secret_scanning_alert":          &SecretScanningAlertEvent{},
		"security_advisory":              &SecurityAdvisoryEvent{},
		"security_and_analysis":          &SecurityAndAnalysisEvent{},
		"star":                           &StarEvent{},
		"status":                         &StatusEvent{},
		"team":                           &TeamEvent{},
		"team_add":                       &TeamAddEvent{},
		"user":                           &UserEvent{},
		"watch":                          &WatchEvent{},
		"workflow_dispatch":              &WorkflowDispatchEvent{},
		"workflow_job":                   &WorkflowJobEvent{},
		"workflow_run":                   &WorkflowRunEvent{},
	}
	// forward mapping of event types to the string names of the structs
	messageToTypeName = make(map[string]string, len(eventTypeMapping))
	// Inverse map of the above
	typeToMessageMapping = make(map[string]string, len(eventTypeMapping))
)

func init() {
	for k, v := range eventTypeMapping {
		typename := reflect.TypeOf(v).Elem().Name()
		messageToTypeName[k] = typename
		typeToMessageMapping[typename] = k
	}
}

// genMAC generates the HMAC signature for a message provided the secret key
// and hashFunc.
func genMAC(message, key []byte, hashFunc func() hash.Hash) []byte {
	mac := hmac.New(hashFunc, key)
	mac.Write(message)
	return mac.Sum(nil)
}

// checkMAC reports whether messageMAC is a valid HMAC tag for message.
func checkMAC(message, messageMAC, key []byte, hashFunc func() hash.Hash) bool {
	expectedMAC := genMAC(message, key, hashFunc)
	return hmac.Equal(messageMAC, expectedMAC)