Loading...

Follow Go Forum | Latest topics on Feedspot

Continue with Google
Continue with Facebook
or

Valid
Go Forum | Latest topics by @root666 Root Zhang - 5h ago

@root666 wrote:

is the date corresponding to the following commit id ?

i’ve download a dependency,

net@v0.0.0-20181011144130-49bb7cea24b1

49bb7cea24b1 this commit id, date at 201810110127, not 20181011144130, but still can be downloaded, so what’s the meaning of the date here ?

Thanks for answering

Posts: 1

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@rjmarshall17 wrote:

Does anyone use badger for key/value storage? I’m trying to use it for a project but it seems to have set the log level to DEBUG because I keep seeing messages like:

badger 2019/06/19 22:11:06 DEBUG: Storing value log head: {Fid:0 Len:43 Offset:16038}
badger 2019/06/19 22:11:06 INFO: Got compaction priority: {level:0 score:1.73 dropPrefix:[]}
badger 2019/06/19 22:11:06 INFO: Running for level: 0
badger 2019/06/19 22:11:06 DEBUG: LOG Compact. Added 5 keys. Skipped 3 keys. Iteration took: 480.685µs
badger 2019/06/19 22:11:06 DEBUG: Discard stats: map[0:424]
badger 2019/06/19 22:11:06 INFO: LOG Compact 0->1, del 2 tables, add 1 tables, took 17.036862ms
badger 2019/06/19 22:11:06 INFO: Compaction for level: 0 DONE
badger 2019/06/19 22:11:06 INFO: Force compaction on level 0 done
badger 2019/06/19 22:11:06 INFO: All 1 tables opened in 0s
badger 2019/06/19 22:11:06 INFO: Replaying file id: 0 at offset: 16081
badger 2019/06/19 22:11:06 INFO: Replay took: 18.347µs

How do I turn them off?

Thanks,

Rob

Posts: 2

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@gt33m wrote:

Hello all,

I’m trying to understand the syntax for this struct. What is new for me is the json tag at the end? Is that specific to json? Never encountered that before…and the tour to go doesn’t seem to have touched upon it, or I missed/forgot it

type response2 struct {
Page int json:"page"
Fruits []string json:"fruits"
}

The parts I do understand is that, we are creating a custom type, with name response2 that is a struct. Struct has two elements:
variable Page of type int
variable Fruits of type []string

What’s the json string?

Posts: 1

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@adriel wrote:

Hello,

Anyone could explain the useful of structure below

type Attribute struct { 
    _ struct { } `type:"structure"`
}

Thank you.

Posts: 1

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@rpreddy wrote:

Hello I am trying to send json payload to server using http.NewRequest. However getting error “http: ContentLength=222 with Body length 0” .

input,_ := json.Marshal(msgin)
req,_ := http.NewRequest(“POST”,url, bytes.NewBuffer(input))

req.Header.Set(“Content-Type”,“application/json”)
client := http.Client{Transport: defaultTransport}
resp, err := client.Do(req)
defer resp.Body.Close()

Posts: 1

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@GoGoGo9 wrote:

Hi everybody,

I am working on a function that validates the update of a user’s password.

I need to reinforce the password with this regular expression:

?=^.{8,}$)(?=.\d)(?=.[a-z])(?=.[A-Z])(?!.\s)[0-9a-zA-Z!@#$%^&()]*$

But I do not know how to implement it in my code.

This is my code :

// UpdatePassword  uptdate the password for this user.
  func UpdatePassword(unitID string, loginID string, password string) (err error) {
f := GetFederation(unitID)
ldap := connections[f.Connection]
hash, err := HashPassword(password, "SSHA", nil)
if err != nil {
    msg := fmt.Sprintf("password hash generation failed for %s. Error: %s", loginID, err.Error())
    return errors.New(msg)
}
originalPasswordHash, err := mdb.GetUserPasswordHash(loginID, f.ID)
if err != nil {
    if err.Error() == mgo.ErrNotFound.Error() && ldap != nil {
        var profile map[string]string
        profile, err = ldap.GetProfile(loginID)
        if err != nil {
            debug.Println("get Profile error ", err)
            return err
        }
        login := profile[config.Connections[f.ID].LoginField]
        loginID, originalPasswordHash, err = ldap.GetPasswordHash(login)
        if err != nil {
            return err
        }
    } else {
        return err
    }
}
if err = mdb.ChangeUserPassword(loginID, f.ID, hash); err != nil {
    debug.Println("ChangeUserPassword error ", err)
    return err
}

if ldap != nil {
    err = ldap.ChangePassword(loginID, password)
    if err != nil {
        info.Printf("revert password change in DB for user %s", loginID)
        if err = mdb.ChangeUserPassword(loginID, f.ID, originalPasswordHash); err != nil {
            return fmt.Errorf("cannot revert password for user %s in DB", loginID)
        }
        return fmt.Errorf("cannot change password for user %s in ldap", loginID)
    }
}

return nil

}

Do you have an idea?

Thank you so much

Posts: 5

Participants: 3

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@hisnameisivan wrote:

I work with .xlsx files using Excelize (“github.com/360EntSecGroup-Skylar/excelize”).
There was a need to identify the text color in the cell.
GetCellStyle does not allow to unambiguously determine the color of the text, as it simply returns an int
How to get text color in a cell?

Posts: 1

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@rjmarshall17 wrote:

I have an application that needs to store some user information in a key/value store. I was thinking about using the user’s one-way encrypted password as the key, but the different methods I’ve tried all create a different hash each time I encrypt the password.

I originally thought about using bcrypt but I don’t want to have to CompareHashAndPassword() through every key to find a match.

Perhaps I’m approaching the problem from the wrong perspective, but is there a way to encrypt a password such that the resultant hash string will always be the same?

Thanks,

Rob

Posts: 2

Participants: 1

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Go Forum | Latest topics by @amarnath_shanbhag Amarnath Shanbha.. - 2d ago

@Amarnath_Shanbhag wrote:

I am a newbie to go. Can someone explain why “go build” does not catch the compile error in the below code while “go test” catches it.

package main

import (
“fmt”
)

func main() {
i := 10
fmt.Println("%d", i)
}

go test
./hello_world.go:9:2: Println call has possible formatting directive %d

This error is expected. However, “go build” does not give any errors.
I would have expected “go test” to do a “go build” first and then run tests (in this
case there are no tests).

Posts: 2

Participants: 2

Read full topic

Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

@oyaro wrote:

Compiler gives syntax error: unexpected map at end of statement.
What’s I do wrong?

func (book Book) GetInfo() map[string]string {
	new_map := make(map[string]string);
	new_map["title"] = book.title;
	new_map["author"] = book.author;
	new_map["subject"] = book.subject;
	new_map["id"] = fmt.Sprintf("%d", book.id);
	new_map["price"] = fmt.Sprintf("%d", book.price);

	if (book.availible) {
		new_map["availible"] = "true";
	} else {
		new_map["availible"] = "false";
	}

	return new_map;
}

Posts: 3

Participants: 3

Read full topic

Read Full Article

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview