Skip to content
Snippets Groups Projects
Unverified Commit 32c584c0 authored by Cseh Viktor's avatar Cseh Viktor
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="PostgreSQL - backend_db@localhost" uuid="719cc097-78f3-4981-b64f-a7946da0d6b8">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
<jdbc-url>jdbc:postgresql://localhost:5432/backend_db</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="GoLibraries">
<option name="urls">
<list>
<option value="file://$USER_HOME$/go" />
</list>
</option>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mobwebhf.iml" filepath="$PROJECT_DIR$/.idea/mobwebhf.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
File added
package db
import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
"mobwebhf/models"
)
func Dbinit() *gorm.DB {
dsn := "host=localhost user=postgres password=almafa dbname=backend_db port=5432 sslmode=disable TimeZone=Europe/Budapest"
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
asd := db.AutoMigrate(&models.Question{})
if asd != nil {
}
return db
}
go.mod 0 → 100644
module mobwebhf
go 1.17
require (
github.com/gin-gonic/gin v1.7.4
gorm.io/driver/postgres v1.1.2
gorm.io/gorm v1.21.16
)
require (
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/golang/protobuf v1.3.3 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.10.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.1.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.8.1 // indirect
github.com/jackc/pgx/v4 v4.13.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.2 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)
go.sum 0 → 100644
This diff is collapsed.
main.go 0 → 100644
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"mobwebhf/db"
)
func something(c *gin.Context){
c.JSON(200, gin.H{
"almafa" : 54,
})
}
func main() {
fmt.Println("alma")
db := db.Dbinit()
if db != nil {
print(db)
}
router := gin.Default()
router.GET("/Almafa", something)
router.Run()
}
package models
import "gorm.io/gorm"
type Question struct{
gorm.Model
QuestionId int `gorm:"not null" json:"questionId"`
QestionText string `gorm:"type:text" json:"questionText"`
Answer1 string `gorm:"type:text" json:"answer1"`
Answer2 string `gorm:"type:text" json:"answer2"`
Answer3 string `gorm:"type:text" json:"answer3"`
Answer4 string `gorm:"type:text" json:"answer4"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment