This commit is contained in:
wagslane
2023-05-01 15:25:27 -06:00
parent f8912668b8
commit 9be3074de6
868 changed files with 58698 additions and 2 deletions

View File

@@ -0,0 +1,28 @@
package main
import "fmt"
type messageToSend struct {
}
// don't edit below this line
func test(m messageToSend) {
fmt.Printf("Sending message: '%s' to: %v\n", m.message, m.phoneNumber)
fmt.Println("====================================")
}
func main() {
test(messageToSend{
phoneNumber: 148255510981,
message: "Thanks for signing up",
})
test(messageToSend{
phoneNumber: 148255510982,
message: "Love to have you aboard!",
})
test(messageToSend{
phoneNumber: 148255510983,
message: "We're so excited to have you",
})
}

View File

@@ -0,0 +1,30 @@
package main
import "fmt"
type messageToSend struct {
phoneNumber int
message string
}
// don't edit below this line
func test(m messageToSend) {
fmt.Printf("Sending message: '%s' to: %v\n", m.message, m.phoneNumber)
fmt.Println("====================================")
}
func main() {
test(messageToSend{
phoneNumber: 148255510981,
message: "Thanks for signing up",
})
test(messageToSend{
phoneNumber: 148255510982,
message: "Love to have you aboard!",
})
test(messageToSend{
phoneNumber: 148255510983,
message: "We're so excited to have you",
})
}

View File

@@ -0,0 +1,6 @@
Sending message: 'Thanks for signing up' to: 148255510981
====================================
Sending message: 'Love to have you aboard!' to: 148255510982
====================================
Sending message: 'We're so excited to have you' to: 148255510983
====================================

View File

@@ -0,0 +1,23 @@
# Structs in Go
We use structs in Go to represent structured data. It's often convenient to group different types of variables together. For example, if we want to represent a car we could do the following:
```go
type car struct {
Make string
Model string
Height int
Width int
}
```
This creates a new struct type called `car`. All cars have a `Make`, `Model`, `Height` and `Width`.
In Go, you will often use a struct to represent information that you would have used a dictionary for in Python, or an object literal for in JavaScript.
## Assignment
Complete the `messageToSend` struct definition. It needs two fields:
* `phoneNumber` - an integer
* `message` - a string.