287 questions
1
vote
0
answers
34
views
Beego ORM `rel(fk)` field causes panic in `getColumnTyp()` when running RunSyncdb
I am trying to define a foreign key field in a Beego ORM model, but the application crashes during RunSyncdb with the following panic:
panic: runtime error: invalid memory address or nil pointer ...
1
vote
1
answer
112
views
Run add .env, so we can use .env params in app.conf with brace?
how can I run and pack with .env file, use bee-cli?, so the app.conf can read .env params with brace, like this:
appname = ${APP_NAME}
In my VSCode launch.json,I set like this:
"configurations&...
1
vote
0
answers
85
views
HTTP file upload in the Beego (or other way with golang)
func (this *MainController) Post() {
file, header, err := this.GetFile("file")
if err != nil {
panic(fmt.Sprintf("failed to get uploaded file: %v", err))
}
...
1
vote
0
answers
66
views
how beego get input type="datetime-local" with ParseForm?
I define a struct in beego and add form tag to realtive fields, and the input type="datetime-local" in html
struct code:
type TaskModifyForm struct {
ID int `form:"...
0
votes
1
answer
77
views
How to display data on web by using .tpl with data from nested json with template is .tpl
I want to display data using beego and golang. But I have a problem because I get is nested json data and I can't find a way to solve it, can you help me cause i'm new in beego and golang.
here's the ...
1
vote
0
answers
423
views
Beego - Annotation routing - Are there extra steps?
I'm using Beego and I don't think the annotation routing works as documented.
My router.go looks like this:
package routers
import (
beego "github.com/beego/beego/v2/server/web"
&...
2
votes
1
answer
407
views
Beego - I need "context.Context" and not the Beego context
I am trying to write a function that will validate a Google id token.
The oauth2 package requires me to pass in the context when creating a new service, like this:
package services
import (
"...
1
vote
0
answers
320
views
Error in Beego framework controller.go , cant figure out the error
ERROR:
*controllers.ListController does not implement web.ControllerInterface (wrong type for Init method)
have Init(*"github.com/astaxie/beego/context".Context, string, string, interface ...
0
votes
1
answer
304
views
How to stop Auto Migration of Database table in Go
I am trying to build an api in beego. I have to make a controller and a model for this project. Model has a database table but the table is not in my database. Beego automatically creates the table in ...
0
votes
1
answer
953
views
How to store data to redis at specific Time interval in Go
I am trying to Set Data to Redis at (6 am, 12 pm, 6 pm and 12 am). But all I can do is setting an expiration time for data caching in redis. Is there any way in Golang to do this?
Code:
err := client....
1
vote
1
answer
808
views
How to avoid generating Default primary key id in Golang (beego) model?
I am trying to create a rest API. I have already a database. I want to create a struct linked to a database table. But when I run the project beego automatically creates an "id" primary key ...
0
votes
1
answer
2k
views
Beego migration: Create index concurrently not working
package main
import (
"github.com/beego/beego/v2/client/orm/migration"
)
// DO NOT MODIFY
type AddConstraintToUser_20210928_223906 struct {
migration.Migration
}
// DO NOT MODIFY
...
0
votes
0
answers
570
views
How to publish a sitemap.xml to my website?
I did not have programming background and I learned to code completely by Google search so please excuse me if the question is not totally clear. I tried to search a this issue but could not find an ...
0
votes
1
answer
444
views
No 'Access-Control-Allow-Origin' header... Is my Beego server misconfigured?
I am using Beego/Golang as my backend and having an issue with No 'Access-Control-Allow-Origin' header when trying to fetch a URL from my domain. I searched on Google and put this in func main() but ...
3
votes
0
answers
452
views
How to mix namespace and restful routing in BeeGo
I'm building a simple project that has an API and serves a dashboard alongside it.
My goal is to have a namespace router (for swagger docs) and a restful router (for the web pages) in the same project,...
1
vote
0
answers
341
views
How to implement H2C (HTTP/2 Plain Text) on Beego Framework
Is there anybody that success implement h2c(HTTP/2 Plain text) Protocol in beego as a server?
I have tried to use http/2 from golang.org/x/net/http2 package using this approach https://beego.me/docs/...
0
votes
1
answer
317
views
Prevent SQL injection in beego
I am using a select query to fetch some rows from my table using the following code.
func (f *UserFilter) ListAllUsers(srch string) (cnt int64, l []*ListResp, err error) {
o := orm.NewOrm()
...
0
votes
1
answer
117
views
Controller returns json as a string
I load a list of items from the database and would like to return it as Json.
it works well but the response is not a json object, its a string with is a problem on the receiver side.
var products []*...
4
votes
1
answer
797
views
How write effective save and update function in beego?
I have the following function in the BaseModel that I can use anywhere.
func (d *Dummy) Save() (int64, error) {
o := orm.NewOrm()
var err error
var count int64
if d.Id == 0 {
...
0
votes
0
answers
186
views
Unable to validate Http response with expected output using golang test and beego framework
I am not able to match response body with expected value
Here is the code i have tried to POST method to create resource
func TestCreateFileShare(t *testing.T) {
var jsonStr = []byte(`{
&...
0
votes
1
answer
770
views
How to validate the JSON message in a POST request with Beego
I'm using Beego to develop a web server.
I used beego.Controller to process the POST requests. In my case, the POST request contains a JSON:
{
"name": "titi",
"...
-1
votes
1
answer
150
views
How to set the project httpport in the non-appconf beego project?
There is an open-source project:
in the application I do not find the httpport config, when I build and run it, there use the 8080. I want to change it. but how?
0
votes
1
answer
573
views
How to dockerzise beego application
I tried to Dockerize a Beego application, but the HTML rendering is not finding HTML files stored inside the view/templates directory.
FROM golang:1.13
WORKDIR /go/src/fileUpload
COPY . .
RUN go get ...
0
votes
1
answer
446
views
how to set a specific key in a struct as a foreign key in beego orm?
I want to set the Coins struct's Address as a foreign key of Accounts struct's address, how to set it in beego orm?
type Coins struct {
Id int `orm:"auto"`
Address string `...
0
votes
2
answers
737
views
How to run Beego binary with production mode in https?
I have my Go app running in https mode. I am using the Beego framework. My app.conf looks like :
appname = myproject
httpsport = 10555
httpport = 8082
runmode = prod
EnableHTTP = false
EnableHTTPS = ...