### Instruction:
Develop a Golang web application that serves as a task manager. The application should use a PostgreSQL database to store tasks and support adding, updating, deleting, and listing tasks through a RESTful API. Implement user authentication using JWT tokens.


### Response:

To create a Golang web application that serves as a task manager, you'll need to follow these steps:

1. Set up your development environment
2. Create the project structure
3. Implement the PostgreSQL database connection and models
4. Implement user authentication with JWT tokens
5. Create RESTful API endpoints for tasks
6. Test the application

Here's an outline of how you can implement each step.

### 1. Set up your development environment

First, make sure you have Go installed on your system. You can download it from https://golang.org/dl/. Also, install PostgreSQL if you haven't already: https://www.postgresql.org/download/.

Next, install the required packages for this project:

```bash
go get -u github.com/gin-gonic/gin
go get -u github.com/jinzhu/gorm
go get -u github.com/jinzhu/gorm/dialects/postgres
go get -u github.com/dgrijalva/jwt-go
```

### 2. Create the project structure

Create a new directory for your project and initialize it as a Go module:

```bash
mkdir go-task-manager
cd go-task-manager
go mod init go-task-manager
```

Now, create the following directories and files inside your project folder:

- `main.go`
- `config/`
  - `config.go`
- `models/`
  - `user.go`
  - `task.go`
- `controllers/`
  - `auth.go`
  - `task.go`
- `middlewares/`
  - `auth.go`

### 3. Implement the PostgreSQL database connection and models

In `config/config.go`, set up the database connection using GORM:

```go
package config

import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/postgres"
)

func GetDB() (*gorm.DB, error) {
	db, err := gorm.Open("postgres", "host=localhost user=youruser dbname=taskmanager password=yourpassword sslmode=disable")
	return db, err
}
```

Replace `youruser` and `yourpassword` with your PostgreSQL credentials.

In `models/user.go`, define the User model:

```go
package models

import (
	"github.com/jinzhu/gorm"
)

type User struct {
	gorm.Model
	Username string `json:"username" gorm:"unique;not null"`
	Password string `json:"password" gorm:"not null"`
}
```

In `models/task.go`, define the Task model:

```go
package models

import (
	"github.com/jinzhu/gorm"
)

type Task struct {
	gorm.Model
	Title       string `json:"title" gorm:"not null"`
	Description string `json:"description"`
	UserID      uint   `json:"user_id" gorm:"not null"`
}
```

### 4. Implement user authentication with JWT tokens

Create functions for registering, logging in, and generating JWT tokens in `controllers/auth.go`. Also, implement a middleware function to protect certain routes in `middlewares/auth.go`.

### 5. Create RESTful API endpoints for tasks

Implement CRUD operations for tasks in `controllers/task.go`. Make sure to use the authentication middleware to protect these routes.

### 6. Test the application

Finally, create the main function in `main.go` to set up the Gin router and register all the necessary routes. Run the application using `go run main.go` and test it using tools like Postman or curl.

This is just an outline of how you can create a task manager web application using Golang, Gin, PostgreSQL, and JWT tokens. You'll need to fill in the details for each step, but this should give you a good starting point.