To run the program, save it as a .swift file and use the Swift compiler:
In Swift, structs are value types, and their methods are non-mutating by default. If you need to modify the struct’s properties within a method, you should mark it as mutating.
Swift doesn’t have a direct equivalent to Go’s pointer receivers, as it handles value and reference semantics differently. Instead, you can use class for reference semantics or mutating methods on structs for value semantics with modification.
Next, we’ll look at Swift’s mechanism for grouping and naming related sets of methods: protocols, which are similar to interfaces in other languages.