Use specified characters within form values ​using Golang [closed] - go

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
I'm trying to build a login page using Golang, but I can't assign specific characters to the form values ​​for username, email, and password.
Found this snippet when I searched for a solution:
if regexp.MustCompile(`^([A-Za-z0-9]{5,})+$`, r.FormValue("username")) == false{
pageinfo.username = "There are disallowed symbols in the field. The allowed characters are: a-zA-Z0-9"
}
The visitor should have shown the pageinfo.username message if he used different characters, but a problem appears:
./user.go:43:54: too many arguments in ca ll to regexp.MustCompile
have (string, string)
want (string)
./user.go:43:76: invalid operation: regexp.MustCompile(`^([A-Za-z0-9]{5,})+$`, r.FormValue("username")) false (mismatched type == s *regexp.Regexp and untyped bool)
make: *** [Makefile:6: main] Error 2
exit status 2
Is there another way to do that?
Note: I am new to using Golang.

Related

r.PostForm() works only if I call before r.PostFormValue() [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
As the title say, I have a code like this:
//if i don't use this line r.postform() don't works and return absolute nothing.
//html form works correctly
// I don't need to call r.PostFormValue for every key, just one
fmt.Println(r.PostFormValue("oldpass"))
if r.PostForm.Has("oldpass") && r.PostForm.Has("newpass1") && r.PostForm.Has("newpass2")
{ //if i don't call r.PostFormValue() the program stop before the if }
}
Make no sense to me... Also I remember to have used it without in the past, so I don't think it depend on parsing the value... What could be?

Accented characters in Sphinx headings [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I want to include accented characters in a Sphinx heading such that I will see the following result:
Finalé
I have tried the following strategies:
Use the unicode character directly such as:
Finalé
======
but the character is considered invalid by Docutils.
Also, I have tried using the strip_html specification in conf.py along with the following text:
Finalé
==============
But the text is left unchanged and the HTML entity is passed through.
Can anyone suggest a way of handling accented characters in Sphinx that will work in all situations and where the final output may be HTML or Latex?

ISO String to Datetime in ruby invalid date? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I am trying to convert a string to a date time object. The string looks like this
"2016-06-16T23:26:25.252Z"
I have been trying to convert it using DateTime.strptime(str,"'%Y-%m-%dT%H:%M:%S.%L%z") but gives invalid date error.
Do any of you know the issue?
Thanks!
You put an extra quotation mark in the string.
str = "2016-06-16T23:26:25.252Z"
DateTime.strptime(str,"'%Y-%m-%dT%H:%M:%S.%L%z") #=> ArgumentError: invalid date
DateTime.strptime(str,"%Y-%m-%dT%H:%M:%S.%L%z") #=> #<DateTime: 2016-06-16T23:26:25+00:00 ((2457556j,84385s,252000000n),+0s,2299161j)>
^^^

Check if Hash is included in output [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am trying to check if a specific element is included in an output. I run:
results.include? {"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100}
but I get an error:
Syntax error, unexpected =>, expecting '}'
What did I do wrong?
The problem is that the curly brackets in this case are interpreted as start of a block. Just put () around:
results.include?({"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100})

Prepared Statement does not insert [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am new to JDBC and trying following code. Could not find the error in it:
try{
Connection con = ConnectionProvider.getCon();
stmt=con.prepareStatement("insert into create_request values((select count(reqno) from create_request)+1,?,?,?,?,?)");
stmt.setString(1,obj_Leaverequest.getUser_name());
stmt.setString(2,obj_Leaverequest.getLeave_Type());
stmt.setInt(3,obj_Leaverequest.getLeave_Units());
stmt.setString(4,obj_Leaverequest.getLeave_Reason());
stmt.setString(5,"pending");
count=stmt.executeUpdate();
if(count>0){
status=true;
}
}
Update:
If I replace my code like this it works:
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Getters are working fine, I could print their values. I guess I am wrong with the query. Please point out my mistake. Thanks in advance!!
String sqQuery="insert into create_request values (?,?,?,?,?,?)";
stmt=con.prepareStatement(sqQuery);
stmt.setString(1,"(select count(reqno) from create_request)+1");
stmt.setString(2,obj_Leaverequest.getUser_name());
stmt.setString(3,obj_Leaverequest.getLeave_Type());
stmt.setInt(4,obj_Leaverequest.getLeave_Units());
stmt.setString(5,obj_Leaverequest.getLeave_Reason());
stmt.setString(6,"pending");
Check for the "?" prepared statements index . You have 6 , but you need only 5
Hope this helps

Resources