Why it is showing `missing ',' before newline in composite literal` [closed] - go

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Why my vscode is showing this error
missing ',' before newline in composite literal
My code:
if title == "" && desc != "" {
msgs = database.UpdateNotification(&Notify, map[string]interface{}{
"Description": changedDesc,
}); msgs != nil {
log.Info("error while deleting notification")
}```

So you want to able to change the variable names dynamically?
There isnt any way of doing this. I suggest if you really need somthing like that you would use a Map.
Data map[String]String
Im not exactly sure what you need this for, or if this helps.

Related

Golang: GetRawData() of ginCtx gets empty value "len:0, cap:512" [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 days ago.
Improve this question
I'm trying to get the body of the request but the method for get it of gin Context does not brings anything.
my endpoint: foo.com/root?q=123
in the controller
bodyInBytes:=ctx.GetRawData()
body is equal to "" len:0, cap:512
get the body of request
my endpoint was: foo.com/root/?country=123
in the controller :
bodyInBytes:=ctx.GetRawData()// body = "" len:0, cap:512
but
country := ctx.Param("country")//country = 123
solution:
change the slash at the end of the endpoint
my endpoint now is: foo.com/root?country=123. (Note I removed the slash )
in the controller :
bodyInBytes:=ctx.GetRawData()// body = "{"test":"Test",} " len:64, cap:512
and
country := ctx.Param("country")//country = 123
by some reason gin don't bring the body when the url has a slash at the end of de endpoint "/"

How to sort a list with and without links alphabetic in Notepad++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to sort many lists alphabetic, but it doesn't work like I want, because some list items has a internal link and some items are not linked. Is it somehow possible to sort such lists, like I need it?
The output have to be in HTML code like my example list.
Here an example list:
<li>aaa</li>
<li>ddd</li>
<li>bbb</li>
<li>eee</li>
<li>ccc</li>
This should be the output
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
<li>ddd</li>
<li>eee</li>
Notepad++ might not get you there, but with a little javascript you can re-arrange the list in a test-page and copy/paste it, or simply re-arrange in place.
Essentially, the code gets all the LI elements contained within a target container. It then passes them to a compare function. If the element contains a link the link's text is used, otherwise, the LIs text is what the comparison is based on.
Other string comparison exercises focus on String.prototype.localeCompare, though I've used what's reported as being higher in performance.
"use strict";
window.addEventListener('load', onLoaded, false);
var strcmp = new Intl.Collator(undefined, {
numeric: true,
sensitivity: 'base'
}).compare;
function onLoaded(evt) {
var items = Array.from(document.querySelectorAll('li'));
var sorted = items.sort(compTextContent);
sorted.forEach(el => document.getElementById('output').appendChild(el.cloneNode(true)));
}
function compTextContent(a, b) {
var linkA = a.querySelector('a');
var linkB = b.querySelector('a');
a = (linkA ? linkA : a);
b = (linkB ? linkB : b);
return strcmp(a.textContent, b.textContent);
}
<div class='unsorted'>
<li>aaa</li>
<li>ddd</li>
<li>bbb</li>
<li>eee</li>
<li>ccc</li>
</div>
<hr>
<div id='output'>
</div>

How do I output name and value of a variable? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am new to VB Script and have a question, how do I assign a Name to the Variables I have input so that they display on the screen?
For example, Once I have input a name I would like the final information box to show the Name value as:
Name: <entered value>
I understand how to assign the 'entered value' but not the 'Name' itself..?
name=inputbox("What is your name?", "Personal Details")
address=inputbox("Please enter your Full Address inc. Post Code", "Address")
tele=inputbox("Please enter your telephone number", "Telephone Number")
msgbox name &vbLf&vbLf& address &vbLf&vbLf& tele, 1, "New Customer Details"
The question isn't very clear so it's quite possible I've misunderstood, but if you just want to know how to add in a static string to your output, then you just add it as "Name: " &.
So combined with your code it would be something like:
msgbox "Name: " &name &vbLf&vbLf& address &vbLf&vbLf& tele, 1, "New Customer Details"

How do I convert ~24000 product titles into URL keys? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have an array with ~24000 products. The hash will be saved as a CSV and uploaded to a Shopify shop using the products import method.
When I manually create a single product, the product url key/handle is automatically generated based on the product title. When using the products import method (CSV), I'll have to specify it myself.
How do I convert the titles into product url keys?
Example:
title_1 = "AH Verse frietaardappelen"
url_key_1 = "ah-verse-frietaardappelen"
title_2 = "Lay's Sensations red sweet paprika"
url_key_2 = "lay-s-sensations-red-sweet-paprika"
I'm currently using:
<title>.downcase.gsub(' ','-').gsub("'", '-')
but this doesn't remove %, $, &, / etc. from the title. I want to make sure the url key/product handle is as clean as possible.
There must be a better way to do this, what could I try next?
There's a (private) to_handle method in Shopify's Liquid gem:
def to_handle(str)
result = str.dup
result.downcase!
result.delete!("'\"()[]")
result.gsub!(/\W+/, '-')
result.gsub!(/-+\z/, '') if result[-1] == '-'
result.gsub!(/\A-+/, '') if result[0] == '-'
result
end
Example:
to_handle("AH Verse frietaardappelen")
#=> "ah-verse-frietaardappelen"
to_handle("Lay's Sensations red sweet paprika")
#=> "lays-sensations-red-sweet-paprika"
Have a look at the gem String Urlize, it may help you write a script to do this.
I would suggest you to use Rails ActiveSupport::Inflector#parameterize solution - http://apidock.com/rails/ActiveSupport/Inflector/parameterize
It handles a lot of edge cases and should work well for you.
The best thing is to use parameterize method:
title_1 = "AH Verse $frietaardappelen".parameterize
Output: "ah-verse-frietaardappelen"
title_2 = "Lay's Sensations red %sweet paprika".parameterize
output: "lay-s-sensations-red-sweet-paprika"

Change format of json output [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
The following method gives me:
ICD1 = []
def parse_kapitel(node)
ICD1 << {von: node.css('~ von_icd_code')[0]['V'],
bis: node.css('~ bis_icd_code')[0]['V'],
bezeichnung: node.css('~ bezeichnung')[0]['V']}
end
File.write('Icd1.json', ICD1)
an output that looks something like this:
[{:von=>"A00", :bis=>"B99", :bezeichnung=>"Bestim.....
But I would like an output that looks like this:
[{"von":"A00", "bis":"B99", "bezeichnung":"Bestim.....
How can I achieve this in an easy ruby way?
Do as below using Generating JSON :
require 'json'
[{ :von=>"A00", :bis=>"B99", :bezeichnung=>"Bestim" }].map(&:to_json)
# => ["{\"von\":\"A00\",\"bis\":\"B99\",\"bezeichnung\":\"Bestim\"}"]

Resources