# 19. User Defined Types

### User Defined Type

We can defined our own type based on existing Go in-build types. We have declared `person` as user defined type based on struct. We are not limited to struct. We can define our type based on any other type as base type.

### Declaring our own type

We can declare our type using `type` keyword. It generally takes form of

`type type_name base_type`

{% code title="main.go" %}

```go
type marks int
type liters float64

var m1 marks
m1 = 20

var l1 liters
l1 = 3.4
```

{% endcode %}

`marks` and `liters` are types based on `int` and `float64` respectively.

> **Go defined types most often use structs as their underlying types, but they can also be based on ints, strings, booleans, or any other type. - Head First Go**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.codewithgo.com/user-defined-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
