To create a Golang web application that allows users to authenticate using OAuth 2.0 with Google or Facebook, you'll need to follow these steps:

1. Set up your project and dependencies
2. Create the PostgreSQL database and tables
3. Register your app with Google and Facebook
4. Implement OAuth 2.0 authentication for Google and Facebook
5. Display user profile information
6. Store user data in the PostgreSQL database

Here's an outline of how you can implement this:

1. Set up your project and dependencies:

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

```bash
mkdir go-oauth-example
cd go-oauth-example
go mod init github.com/yourusername/go-oauth-example
```

Install the required dependencies:

```bash
go get -u github.com/gin-gonic/gin
go get -u golang.org/x/oauth2
go get -u github.com/lib/pq
```

2. Create the PostgreSQL database and tables:

Assuming you have PostgreSQL installed, create a new database and table to store user information:

```sql
CREATE DATABASE oauth_example;

\c oauth_example;

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255),
    email VARCHAR(255) UNIQUE NOT NULL,
    picture_url VARCHAR(255)
);
```

3. Register your app with Google and Facebook:

- For Google: Follow the instructions at https://developers.google.com/identity/sign-in/web/sign-in#before_you_begin to create a new project and obtain your client ID and secret.
- For Facebook: Follow the instructions at https://developers.facebook.com/docs/facebook-login/web/#simple-app to create a new app and obtain your App ID and secret.

4. Implement OAuth 2.0 authentication for Google and Facebook:

Create a `main.go` file in your project directory and add the following code:

```go
package main

import (
	"database/sql"
	"fmt"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
	_ "github.com/lib/pq"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/facebook"
	"golang.org/x/oauth2/google"
)

const (
	host     = "localhost"
	port     = 5432
	user     = "your_db_user"
	password = "your_db_password"
	dbname   = "oauth_example"
)

var (
	googleOauthConfig = &oauth2.Config{
		ClientID:     "your_google_client_id",
		ClientSecret: "your_google_client_secret",
		RedirectURL:  "http://localhost:8080/auth/google/callback",
		Scopes:       []string{"https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"},
		Endpoint:     google.Endpoint,
	}
	facebookOauthConfig = &oauth2.Config{
		ClientID:     "your_facebook_app_id",
		ClientSecret: "your_facebook_app_secret",
		RedirectURL:  "http://localhost:8080/auth/facebook/callback",
		Scopes:       []string{"public_profile", "email"},
		Endpoint:     facebook.Endpoint,
	}
	oauthStateString = "random_state_string"
)

func main() {
	router := gin.Default()

	router.LoadHTMLGlob("templates/*")

	router.GET("/", indexHandler)
	router.GET("/login", loginHandler)
	router.GET("/auth/google/login", beginGoogleOAuth)
	router.GET("/auth/google/callback", handleGoogleOAuthCallback)
	router.GET("/auth/facebook/login", beginFacebookOAuth)
	router.GET("/auth/facebook/callback", handleFacebookOAuthCallback)

	err := router.Run(":8080")
	if err != nil {
		log.Fatal(err)
	}
}

func indexHandler(c *gin.Context) {
	c.HTML(http.StatusOK, "index.html", nil)
}

func loginHandler(c *gin.Context) {
	c.HTML(http.StatusOK, "login.html", nil)
}

func beginGoogleOAuth(c *gin.Context) {
	url := googleOauthConfig.AuthCodeURL(oauthStateString)
	c.Redirect(http.StatusTemporaryRedirect, url)
}

func handleGoogleOAuthCallback(c *gin.Context) {
	// Implement the logic to exchange the authorization code for an access token,
	// retrieve user profile information and store it in the PostgreSQL database.
}

func beginFacebookOAuth(c *gin.Context) {
	url := facebookOauthConfig.AuthCodeURL(oauthStateString)
	c.Redirect(http.StatusTemporaryRedirect, url)
}

func handleFacebookOAuthCallback(c *gin.Context) {
	// Implement the logic to exchange the authorization code for an access token,
	// retrieve user profile information and store it in the PostgreSQL database.
}
```

5. Display user profile information:

Create a `templates` directory in your project folder and add two HTML files: `index.html` and `login.html`.

`index.html`:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Go OAuth Example</title>
</head>
<body>
    <h1>Welcome!</h1>
    <a href="/login">Login with Google or Facebook</a>
</body>
</html>
```

`login.html`:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login</title>
</head>
<body>
    <h1>Login</h1>
    <a href="/auth/google/login">Login with Google</a><br>
    <a href="/auth/facebook/login">Login with Facebook</a>
</body>
</html>
```

6. Store user data in the PostgreSQL database:

Update the `handleGoogleOAuthCallback` and `handleFacebookOAuthCallback` functions in your `main.go` file to exchange the authorization code for an access token, retrieve user profile information, and store it in the PostgreSQL database.

You can find examples of how to do this in the following articles:

- For Google: https://developers.google.com/identity/sign-in/web/backend-auth
- For Facebook: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/#logindialog

After completing these steps, you should have a working Golang web application that allows users to authenticate using OAuth 2.0 with Google or Facebook, displays their profile information, and stores this data in a PostgreSQL database.
사용자가 Google 또는 Facebook에서 OAuth 2.0을 사용하여 인증할 수 있는 Golang 웹 애플리케이션을 만들려면 다음 단계를 따라야 합니다.

1. 프로젝트 및 종속성 설정
2. PostgreSQL 데이터베이스 및 테이블 생성
3. 구글과 페이스북에 앱을 등록합니다
4. 구글과 페이스북을 위한 OAuth 2.0 인증 구현하기
5. 사용자 프로필 정보 표시
6. 사용자 데이터를 PostgreSQL 데이터베이스에 저장

이를 구현하는 방법에 대한 개요는 다음과 같습니다.

1. 프로젝트 및 종속성 설정하기

프로젝트를 위한 새 디렉터리를 생성하고 Go 모듈로 초기화합니다:

```bash
mkdir go-oauth-example
cd go-oauth-example
go mod init github.com/yourusername/go-oauth-example
```

필요한 종속성을 설치합니다:

```bash
go get -u github.com/gin-gonic/gin
go get -u golang.org/x/oauth2
go get -u github.com/lib/pq
```

2. 2. PostgreSQL 데이터베이스 및 테이블을 생성합니다:

PostgreSQL이 설치되어 있다고 가정하고 사용자 정보를 저장할 새 데이터베이스와 테이블을 만듭니다:

```sql
CREATE DATABASE oauth_example;

\c oauth_example;

CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255),
    email VARCHAR(255) UNIQUE NOT NULL,
    picture_url VARCHAR(255)
);
```

3. Google 및 Facebook에 앱을 등록합니다:

- Google의 경우: https://developers.google.com/identity/sign-in/web/sign-in#before_you_begin 의 지침에 따라 새 프로젝트를 생성하고 클라이언트 ID와 비밀번호를 받습니다.
- Facebook의 경우: https://developers.facebook.com/docs/facebook-login/web/#simple-app 의 지침에 따라 새 앱을 만들고 앱 ID와 비밀번호를 받습니다.

4. Google 및 Facebook용 OAuth 2.0 인증 구현하기:

프로젝트 디렉터리에 `main.go` 파일을 생성하고 다음 코드를 추가합니다:

```go
package main

import (
	"database/sql"
	"fmt"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
	_ "github.com/lib/pq"
	"golang.org/x/oauth2"
	"golang.org/x/oauth2/facebook"
	"golang.org/x/oauth2/google"
)

const (
	host     = "localhost"
	port     = 5432
	user     = "your_db_user"
	password = "your_db_password"
	dbname   = "oauth_example"
)

var (
	googleOauthConfig = &oauth2.Config{
		ClientID:     "your_google_client_id",
		ClientSecret: "your_google_client_secret",
		RedirectURL:  "http://localhost:8080/auth/google/callback",
		Scopes:       []string{"https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"},
		Endpoint:     google.Endpoint,
	}
	facebookOauthConfig = &oauth2.Config{
		ClientID:     "your_facebook_app_id",
		ClientSecret: "your_facebook_app_secret",
		RedirectURL:  "http://localhost:8080/auth/facebook/callback",
		Scopes:       []string{"public_profile", "email"},
		Endpoint:     facebook.Endpoint,
	}
	oauthStateString = "random_state_string"
)

func main() {
	router := gin.Default()

	router.LoadHTMLGlob("templates/*")

	router.GET("/", indexHandler)
	router.GET("/login", loginHandler)
	router.GET("/auth/google/login", beginGoogleOAuth)
	router.GET("/auth/google/callback", handleGoogleOAuthCallback)
	router.GET("/auth/facebook/login", beginFacebookOAuth)
	router.GET("/auth/facebook/callback", handleFacebookOAuthCallback)

	err := router.Run(":8080")
	if err != nil {
		log.Fatal(err)
	}
}

func indexHandler(c *gin.Context) {
	c.HTML(http.StatusOK, "index.html", nil)
}

func loginHandler(c *gin.Context) {
	c.HTML(http.StatusOK, "login.html", nil)
}

func beginGoogleOAuth(c *gin.Context) {
	url := googleOauthConfig.AuthCodeURL(oauthStateString)
	c.Redirect(http.StatusTemporaryRedirect, url)
}

func handleGoogleOAuthCallback(c *gin.Context) {
	// Implement the logic to exchange the authorization code for an access token,
	// retrieve user profile information and store it in the PostgreSQL database.
}

func beginFacebookOAuth(c *gin.Context) {
	url := facebookOauthConfig.AuthCodeURL(oauthStateString)
	c.Redirect(http.StatusTemporaryRedirect, url)
}

func handleFacebookOAuthCallback(c *gin.Context) {
	// Implement the logic to exchange the authorization code for an access token,
	// retrieve user profile information and store it in the PostgreSQL database.
}
```

5. 사용자 프로필 정보 표시:

프로젝트 폴더에 `templates` 디렉터리를 생성하고 두 개의 HTML 파일을 추가합니다: `index.html`과 `login.html`을 추가합니다.

`index.html`:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Go OAuth Example</title>
</head>
<body>
    <h1>Welcome!</h1>
    <a href="/login">Login with Google or Facebook</a>
</body>
</html>
```

`login.html`:

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Login</title>
</head>
<body>
    <h1>Login</h1>
    <a href="/auth/google/login">Login with Google</a><br>
    <a href="/auth/facebook/login">Login with Facebook</a>
</body>
</html>
```

6. 사용자 데이터를 PostgreSQL 데이터베이스에 저장합니다.

`main.go` 파일에서 `handleGoogleOAuthCallback` 및 `handleFacebookOAuthCallback` 함수를 업데이트하여 인증 코드를 액세스 토큰으로 교환하고 사용자 프로필 정보를 검색하여 PostgreSQL 데이터베이스에 저장합니다.

이 작업의 예는 다음 문서에서 찾을 수 있습니다.

- Google의 경우: https://developers. google.com/identity/sign-in/web/backend-auth
- Facebook의 경우: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/#logindialog

이 단계를 완료하면 사용자가 Google 또는 Facebook에서 OAuth 2.0을 사용하여 인증하고 프로필 정보를 표시하며 이 데이터를 PostgreSQL 데이터베이스에 저장할 수 있는 작동하는 Golang 웹 애플리케이션이 있어야 합니다.